QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768562#8020. Mine Sweeper IIsurenjamts#RE 1ms3800kbC++202.0kb2024-11-21 12:18:282024-11-21 12:18:29

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 12:18:29]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3800kb
  • [2024-11-21 12:18:28]
  • 提交

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";
}

詳細信息

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......

output:


result: