Submission #73131314
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
int n, val[MAXN << 1]; char s[MAXN][MAXN];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
memset(val, 0xff, sizeof val);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
int k = i + j;
if (s[i][j] == '?') continue;
if (val[k] == -1) val[k] = s[i][j] - '0';
else if (val[k] != s[i][j] - '0') return puts("-1"), 0;
}
}
for (int i = 1; i <= n * 2; i++) if (val[i] == -1) val[i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
int k = i + j;
if (s[i][j] == '?') s[i][j] = val[k] + '0';
}
}
for (int i = 1; i <= n; i++) printf("%s\n", s[i] + 1);
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Same Sum Grid Path |
| User | Register_int |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 749 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3884 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 1 ms | 3736 KiB |
| 01-02.txt | AC | 1 ms | 3608 KiB |
| 01-03.txt | AC | 1 ms | 3760 KiB |
| 01-04.txt | AC | 1 ms | 3640 KiB |
| 01-05.txt | AC | 1 ms | 3736 KiB |
| 01-06.txt | AC | 1 ms | 3840 KiB |
| 01-07.txt | AC | 1 ms | 3760 KiB |
| 01-08.txt | AC | 1 ms | 3620 KiB |
| 01-09.txt | AC | 1 ms | 3844 KiB |
| 01-10.txt | AC | 1 ms | 3640 KiB |
| 01-11.txt | AC | 1 ms | 3884 KiB |
| 01-12.txt | AC | 1 ms | 3760 KiB |
| 01-13.txt | AC | 1 ms | 3788 KiB |
| sample-01.txt | AC | 1 ms | 3840 KiB |
| sample-02.txt | AC | 1 ms | 3844 KiB |
| sample-03.txt | AC | 1 ms | 3608 KiB |