-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (34 loc) · 817 Bytes
/
Copy pathmain.cpp
File metadata and controls
36 lines (34 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
auto sol = [](int n, auto v) {
for (int iter = 0; iter <= 2 * n - 2; iter++) {
int val = -1;
for (int i = 0; i < n; i++) {
int j = iter - i;
if (j < 0 || j >= n) continue;
if (v[i][j] == '?') continue;
if (val == -1) val = v[i][j] - 48;
if (val != v[i][j] - 48) return vector(0, string{});
}
if (val == -1) val = 0;
for (int i = 0; i < n; i++) {
int j = iter - i;
if (j < 0 || j >= n) continue;
v[i][j] = val + 48;
}
}
return v;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector v(n, string{});
for (int i = 0; i < n; i++) cin >> v[i];
auto res = sol(n, v);
if (res.size()) {
for (int i = 0; i < n; i++) cout << res[i] << '\n';
}
else {
cout << -1 << '\n';
}
}