QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#456823#8519. RadarssupepapupuWA 0ms3872kbC++201.6kb2024-06-28 14:46:212024-06-28 14:46:21

Judging History

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

  • [2024-06-28 14:46:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-06-28 14:46:21]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;

void solve() {
    int n; cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n));
    for (int i = 0; i < n; ++i) 
        for (int j = 0; j < n; ++j) 
            cin >> a[i][j];
    ll ans = a[n / 2][n / 2];
    if (n == 1) return cout << ans << el, void();
    vector<ll> x, y;
    for (int i = 0; i < n; ++i) x.emplace_back(a[n / 2][i]), y.emplace_back(a[i][n / 2]);
    sort(x.begin(), x.end()), sort(y.begin(), y.end());
    ans = min({ans, x[0] + x[1], y[0] + y[1]});
    vector<vector<ll>> b(2, vector<ll>(2, INF));
    for (int i = 0; i < n / 2; ++i) 
        for (int j = 0; j < n / 2; ++j) 
            for (int x = 0; x < 2; ++x) 
                for (int y = 0; y < 2; ++y) 
                    b[x][y] = min(b[x][y], a[i + (n / 2 + 1) * x][j + (n / 2 + 1) * y]);
    ans = min(ans, b[0][0] + b[0][1] + b[1][0] + b[1][1]);
    for (int i = 0; i < n; ++i) {
        if (i < n / 2) {
            ans = min(ans, a[i][n / 2] + b[1][0] + b[1][1]);
            ans = min(ans, a[n / 2][i] + b[0][1] + b[1][1]);
        } else {
            ans = min(ans, a[i][n / 2] + b[0][0] + b[0][1]);
            ans = min(ans, a[n / 2][i] + b[0][0] + b[1][0]);
        }
    }
    cout << ans << el;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int tcase = 1;
    cin >> tcase;
    while (tcase--) solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3872kb

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
5

result:

ok 2 number(s): "1 5"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

1
1
444739567

output:

444739567

result:

ok 1 number(s): "444739567"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

32
5
177252602 814271963 432801178 401470194 888319541
320323627 34071000 116035631 87392694 926990496
423510770 515133425 777623990 140441392 853473387
976288681 925949889 930584554 939702106 761328886
840677679 912446055 378955738 997133668 334407172
3
633852912 89450314 828384045
327867173 732812...

output:

494991369
661643843
52707681
190261304
50684672
954430705
139405747
551797206
199272913
175039535
333898451
217089022
35580250
251879512
230866303
60323753
215243437
114032585
147200354
361741480
49710371
75128942
269414925
755829169
133537759
108744675
691515792
193230413
469380143
156043031
227141...

result:

wrong answer 3rd numbers differ - expected: '47298040', found: '52707681'