Submission #65455300
Source Code Expand
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <ctime>
#include <map>
#include <set>
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define mpair make_pair
#define ld long double
#define vi vector<int>
#define ll long long
#define ss second
#define ff first
using namespace std;
const ll lINF = 1000000000000000007;
const int iINF = 1000000007;
const int INF = 1e5+1;
/*
0 0 -> 0, n-1
0 1 -> 1, n-1
1 0
*/
vector<vector<char>> rotate(vector<vector<char>>& ar){
int sz = ar.size();
vector <vector<char>> ans(sz, vector<char>(sz));
for(int i = 0; i < sz; ++ i){
for(int j = 0; j < sz; ++ j){
ans[j][sz-1-i] = ar[i][j];
}
}
return ans;
}
int get_operation(int num, vector<vector<char>>& s, vector<vector<char>>& t){
int wtob = 0, cnt = 0;
int n = s.size();
for(int i = 0; i < n; ++ i){
for(int j = 0; j < n; ++ j){
if(s[i][j] != t[i][j]) cnt ++;
}
}
return cnt + num;
}
void solve(){
int n; cin >> n;
vector <vector<char>> s(n, vector<char>(n)), t(n, vector<char>(n)), cur;
for(int i = 0; i < n; ++ i){
for(int j = 0; j < n; ++ j){
cin >> s[i][j];
}
}
for(int i = 0; i < n; ++ i){
for(int j = 0; j < n; ++ j){
cin >> t[i][j];
}
}
cur = s;
int mn = get_operation(0, cur, t);
cur = rotate(s);
mn = min(mn, get_operation(1, cur, t));
cur = rotate(cur);
mn = min(mn, get_operation(2, cur, t));
cur = rotate(cur);
mn = min(mn, get_operation(3, cur, t));
cout << mn;
// for(int i = 0; i < n; ++ i){
// for(int j = 0; j < n; ++ j){
// cout << cur[i][j];
// }
// cout << '\n';
// }
// cout << "\n\n";
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int tt = 1;
// cin >> tt;
while(tt --){
solve();
cout << '\n';
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Grid Rotation |
| User |
dusanov |
| Language |
C++ 17 (gcc 12.2) |
| Score |
250 |
| Code Size |
2006 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3604 KiB |
Compile Error
Main.cpp: In function ‘int get_operation(int, std::vector<std::vector<char> >&, std::vector<std::vector<char> >&)’:
Main.cpp:51:13: warning: unused variable ‘wtob’ [-Wunused-variable]
51 | int wtob = 0, cnt = 0;
| ^~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
250 / 250 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt |
| All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| random_01.txt |
AC |
1 ms |
3448 KiB |
| random_02.txt |
AC |
1 ms |
3604 KiB |
| random_03.txt |
AC |
1 ms |
3308 KiB |
| random_04.txt |
AC |
1 ms |
3484 KiB |
| random_05.txt |
AC |
1 ms |
3388 KiB |
| random_06.txt |
AC |
1 ms |
3308 KiB |
| random_07.txt |
AC |
1 ms |
3320 KiB |
| random_08.txt |
AC |
1 ms |
3420 KiB |
| random_09.txt |
AC |
1 ms |
3460 KiB |
| random_10.txt |
AC |
1 ms |
3492 KiB |
| random_11.txt |
AC |
1 ms |
3516 KiB |
| random_12.txt |
AC |
1 ms |
3504 KiB |
| random_13.txt |
AC |
1 ms |
3516 KiB |
| random_14.txt |
AC |
1 ms |
3496 KiB |
| random_15.txt |
AC |
1 ms |
3552 KiB |
| random_16.txt |
AC |
1 ms |
3512 KiB |
| random_17.txt |
AC |
1 ms |
3448 KiB |
| random_18.txt |
AC |
1 ms |
3448 KiB |
| random_19.txt |
AC |
1 ms |
3408 KiB |
| sample_01.txt |
AC |
1 ms |
3588 KiB |
| sample_02.txt |
AC |
1 ms |
3424 KiB |