QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768577 | #8020. Mine Sweeper II | surenjamts# | WA | 0ms | 3752kb | C++20 | 1.8kb | 2024-11-21 12:33:27 | 2024-11-21 12:33:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string a[1045], b[1045], c[1045];
int n, m;
void init(){
for(int i = 0; i < n; i ++ ){
c[i] = a[i];
}
}
void rotate(){
int ogn = n, ogm = m;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
//a[i][j]
c[j][n-i-1] = a[i][j];
}
}
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
//a[i][j]
a[i][j] = c[i][j];
}
}
}
int check(){
int cnt = 0;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
if( c[i][j] != b[i][j] ){
cnt ++;
}
}
}
if( cnt <= (n*m)/2 ){
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
cout << c[i][j];
}
cout << "\n";
}
return 1;
}
return 0;
}
void rotate180u(){
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
c[i][j] = a[n-1-i][j];
}
}
}
void rotate180r(){
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
c[i][j] = a[i][m-1-j];
}
}
}
signed main(){
cin >> n >> m;
for(int i = 0; i < n; i ++ ){
cin >> a[i];
}
for(int i = 0; i < n; i ++ ){
cin >> b[i];
}
init();
if( n != m ){
rotate180u();
if( check() ){
return 0;
}
rotate180r();
if( check() ){
return 0;
}
cout << "-1\n";
return 0;
}
for(int i = 1; i <= 4; i ++ ){
if( check() ){
return 0;
}
rotate();
}
cout << "-1\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
2 4 X..X X.X. X.X. .X..
output:
X.X. X..X
result:
ok OK, Accepted.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
7 28 ............................ .XXXXX...XXXX..XXXX....XXXX. ...X....XX.....X..XX..XX.... ...X....X......XXXX...X..... ...X....XX.....X......XX.... .XXXXX...XXXX..X.......XXXX. ............................ ............................ ..XXXX...XXXX..XXXXX..X...X. .XX.....XX.......X....X...X. .X......
output:
............................ .XXXXX...XXXX..X.......XXXX. ...X....XX.....X......XX.... ...X....X......XXXX...X..... ...X....XX.....X..XX..XX.... .XXXXX...XXXX..XXXX....XXXX. ............................
result:
ok OK, Accepted.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3752kb
input:
1 1 . X
output:
-1
result:
wrong answer Line "-1" doesn't correspond to pattern "[.X]{1}"