QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768562 | #8020. Mine Sweeper II | surenjamts# | RE | 1ms | 3800kb | C++20 | 2.0kb | 2024-11-21 12:18:28 | 2024-11-21 12:18:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
string a[1045], b[1045], c[1045];
int n, m;
void init(){
for(int i = 0; i < n; i ++ ){
c[i] = a[i];
}
}
void clearc(){
for(int i = 0; i < max(n,m); i ++ ){
for(int j = 0; j < max(n,m); j ++ ){
c[i][j] = ' ';
}
}
}
void rotate(){
clearc();
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(){
init();
cin >> n >> m;
for(int i = 0; i < n; i ++ ){
cin >> a[i];
}
for(int i = 0; i < n; i ++ ){
cin >> b[i];
}
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: 1ms
memory: 3800kb
input:
2 4 X..X X.X. X.X. .X..
output:
X.X. X..X
result:
ok OK, Accepted.
Test #2:
score: -100
Runtime Error
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......