#include <bits/stdc++.h>
using namespace std;
int n, c[11][22], bd[11];
char b[11][22];
void f(int x, int y);
void g(int x, int y, int x1, int y1, int x2, int y2, int nxt, int col){
if(y1 <= 0 || y2 <= 0) return;
if(b[x1][y1] == '0' && b[x2][y2] == '0'){
c[x][y] = c[x1][y1] = c[x2][y2] = col;
b[x1][y1] = b[x2][y2] = '.';
f(x, y + nxt);
c[x][y] = c[x1][y1] = c[x2][y2] = 0;
b[x1][y1] = b[x2][y2] = '0';
}
}
void f(int x, int y){
if(x > 2 * n){
for(int i = 1; i <= 2 * n; i++){
for(int j = max(1, 2 * (i - n)); j < bd[i]; j++){
putchar(c[i][j] ? c[i][j] + '0' : '.');
}
puts("");
}
exit(0);
}
if(y == bd[x]){ f(x + 1, 1); return; }
if(b[x][y] != '0'){ f(x, y + 1); return; }
int q = (x % 3), w = ((y + 1) / 2) % 2;
if(y % 2){
g(x, y, x, y + 1, x, y + 2, 3, (q + (3 ^ w) + 1) % 6 + 1);
g(x, y, x, y + 1, x + 1, y + 1, 2, (q + (3 ^ w) + 2) % 6 + 1);
g(x, y, x + 1, y, x + 1, y + 1, 1, (q + (2 ^ w) + 3) % 6 + 1);
g(x, y, x + 1, y + 1, x + 1, y + 2, 1, (q + (3 ^ w) + 4) % 6 + 1);
}
else{
g(x, y, x, y + 1, x, y + 2, 3, (q + (1 ^ w) + 5) % 6 + 1);
g(x, y, x, y + 1, x + 1, y + 2, 2, (q + (3 ^ w)) % 6 + 1);
}
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= 2 * n; i++){
scanf("%s", b[i] + max(1, 2 * (i - n)));
for(bd[i] = max(1, 2 * (i - n)); b[i][bd[i]]; bd[i]++);
}
f(1, 1);
puts("nemoguce");
}
Compilation message
trapezi.cpp: In function 'int main()':
trapezi.cpp:46:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
trapezi.cpp:48:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", b[i] + max(1, 2 * (i - n)));
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2020 KB |
Output is correct |
2 |
Correct |
0 ms |
2020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |