QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#231867 | #7042. So Easy | Ycfhnnd | WA | 0ms | 3820kb | C++17 | 1.3kb | 2023-10-29 17:23:33 | 2023-10-29 17:23:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
int n;
cin >> n;
vector<vector<int>>a(n + 1, vector<int>(n + 1));
int x = 0, y = 0;
for (int i = 1;i <= n;i ++){
for (int j = 1;j <= n;j ++){
cin >> a[i][j];
if (a[i][j] == -1){
x = i, y = j;
}
}
}
int res = 0;
int b = -1, c = -1, d = -1, e = -1;// 左上右下
if (x > 1){
b = a[x - 1][y];
}
if (y > 1){
c = a[x][y - 1];
}
if (x < n){
d = a[x + 1][y];
}
if (y < n){
e = a[x][y + 1];
}
if (b != -1 || d != -1){
int t = 0x3f3f3f3f;
if (b != -1){
t = min(t, b);
}
if (d != -1){
t = min(t, d);
}
res += t;
}
if (c != -1 || e != -1){
int t = 0x3f3f3f3f;
if (c != -1){
t = min(c, t);
}
if (e != -1){
t = min(e, t);
}
res += t;
}
cout << res << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
3 1 2 1 0 -1 0 0 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3820kb
input:
10 63 66 64 39 41 64 67 46 45 56 67 70 68 43 45 68 71 50 49 60 72 75 73 48 50 73 76 55 54 65 64 67 65 40 42 65 68 47 46 57 81 84 82 57 59 82 85 64 63 74 43 46 44 19 21 44 47 26 25 36 45 48 46 21 23 -1 49 28 27 38 70 73 71 46 48 71 74 53 52 63 57 60 58 33 35 58 61 40 39 50 81 84 82 57 59 82 85 64 63 74
output:
67
result:
wrong answer 1st numbers differ - expected: '46', found: '67'