QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#451417#8519. RadarsHKOI0#WA 0ms3552kbC++202.0kb2024-06-23 11:21:062024-06-23 11:21:06

Judging History

你现在查看的是最新测评结果

  • [2024-06-23 11:21:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-06-23 11:21:06]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

void solve() {
    int n; cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n, 0));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];

    if (n == 1) {
        cout << a[0][0] << '\n';
        return;
    }

    const int w = n / 2;

    vector<ll> cost(9, LLONG_MAX);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int region = 0;
            if (i == w) region += 3;
            if (i > w) region += 6;
            if (j == w) region += 1;
            if (j > w) region += 2;

            cost[region] = min(cost[region], a[i][j]);
        }
    }

    const int corr[] = { 1, 3, 4, 5, 7 };
    const int corner[] = { 0, 2, 6, 8 };
    ll ans = LLONG_MAX;
    for (int mask = 0; mask < 32; mask++) {
        vector<bool> covered(4, false);

        ll val = 0;
        for (int bit = 0; bit < 5; bit++) {
            if (mask >> bit & 1) {
                const int region = corr[bit];
                val += cost[region];

                const int row = region / 3;
                const int col = region % 3;

                if (row <= 1 && col <= 1) covered[0] = true;
                if (row <= 1 && col >= 1) covered[1] = true;
                if (row >= 1 && col <= 1) covered[2] = true;
                if (row >= 1 && col >= 1) covered[3] = true;
            }
        }
        
        for (int corn = 0; corn < 4; corn++) {
            const int region = corr[corn];
            if (!covered[corn])
                val += cost[region];
        }

        ans = min(ans, val);
    }

    cout << ans << '\n';
}

signed main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

2
3
1 1 1
1 1 1
1 1 1
5
8 5 2 8 3
5 6 9 7 3
7 8 9 1 4
8 9 4 5 5
2 8 6 9 3

output:

1
6

result:

wrong answer 2nd numbers differ - expected: '5', found: '6'