Submission #65429677
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long
#define PII pair<int,int>
#define mod 998244353
const int MOD=1e9+7;
const int N=1e5+10;
int read() {char act = 0;int f = 1, x= 0;while (act = getchar(), act < '0' && act != '-');if (act == '-') f = -1, act = getchar();x = act - '0';while (act = getchar(), act >= '0') x = x * 10 + act - '0';return x * f;}
vector<string> rotate90(const vector<string>& grid) {
int n = grid.size();
vector<string> new_grid(n, string(n, '.'));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
new_grid[i][j] = grid[n - 1 - j][i];
}
}
return new_grid;
}
int cal(const vector<string>& a, const vector<string>& b) {
int cnt = 0;
int n = a.size();
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (a[i][j] != b[i][j]) {
cnt++;
}
}
}
return cnt;
}
signed main() {
int N;
cin >> N;
vector<string> S(N), T(N);
for (int i = 0; i < N; ++i) {
cin >> S[i];
}
for (int i = 0; i < N; ++i) {
cin >> T[i];
}
vector<vector<string>> rotations;
rotations.push_back(S);
vector<string> s1 = rotate90(S);
rotations.push_back(s1);
vector<string> s2 = rotate90(s1);
rotations.push_back(s2);
vector<string> s3 = rotate90(s2);
rotations.push_back(s3);
int ans = 1e9;
for (int k = 0; k < 4; ++k) {
int dif = cal(rotations[k], T);
int ops = k + dif;
if (ops < ans) {
ans = ops;
}
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Grid Rotation |
| User | Freakkk |
| Language | C++ 20 (gcc 12.2) |
| Score | 250 |
| Code Size | 1825 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3660 KiB |
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 | 3660 KiB |
| random_02.txt | AC | 1 ms | 3512 KiB |
| random_03.txt | AC | 1 ms | 3496 KiB |
| random_04.txt | AC | 1 ms | 3564 KiB |
| random_05.txt | AC | 1 ms | 3480 KiB |
| random_06.txt | AC | 1 ms | 3484 KiB |
| random_07.txt | AC | 1 ms | 3356 KiB |
| random_08.txt | AC | 1 ms | 3556 KiB |
| random_09.txt | AC | 1 ms | 3568 KiB |
| random_10.txt | AC | 1 ms | 3596 KiB |
| random_11.txt | AC | 1 ms | 3600 KiB |
| random_12.txt | AC | 1 ms | 3604 KiB |
| random_13.txt | AC | 1 ms | 3656 KiB |
| random_14.txt | AC | 1 ms | 3592 KiB |
| random_15.txt | AC | 1 ms | 3660 KiB |
| random_16.txt | AC | 1 ms | 3636 KiB |
| random_17.txt | AC | 1 ms | 3456 KiB |
| random_18.txt | AC | 1 ms | 3500 KiB |
| random_19.txt | AC | 1 ms | 3472 KiB |
| sample_01.txt | AC | 1 ms | 3576 KiB |
| sample_02.txt | AC | 1 ms | 3448 KiB |