Submission #66191913
Source Code Expand
Copy
#include <stdio.h>int N;char S[4096][4096];char T[4096][4096];int main(void) {int i, j, k;int ans;if (scanf("%d", &N) != 1) return 1;for (i = 0; i < N; i++) {if (scanf("%4095s", S[i]) != 1) return 1;}for (i = 0; i < N; i++) {if (scanf("%4095s", T[i]) != 1) return 1;}ans = N * N + 100;for (k = 0; k < 4; k++) {/* 違う場所の数を数える */int cur = 0;for (i = 0; i < N; i++) {
#include <stdio.h>
int N;
char S[4096][4096];
char T[4096][4096];
int main(void) {
int i, j, k;
int ans;
if (scanf("%d", &N) != 1) return 1;
for (i = 0; i < N; i++) {
if (scanf("%4095s", S[i]) != 1) return 1;
}
for (i = 0; i < N; i++) {
if (scanf("%4095s", T[i]) != 1) return 1;
}
ans = N * N + 100;
for (k = 0; k < 4; k++) {
/* 違う場所の数を数える */
int cur = 0;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
cur += S[i][j] != T[i][j];
}
}
if (k + cur < ans) ans = k + cur;
/* 回転させる */
for (i = 0; i < N - 1 - i; i++) {
for (j = 0; j < N - i * 2 - 1; j++) {
char t = S[i][i + j];
S[i][i + j] = S[N - 1 - i - j][i];
S[N - 1 - i - j][i] = S[N - 1 - i][N - 1 - i - j];
S[N - 1 - i][N - 1 - i - j] = S[i + j][N - 1 - i];
S[i + j][N - 1 - i] = t;
}
}
}
printf("%d\n", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Grid Rotation |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 250 |
| Code Size | 920 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 2548 KB |
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 | 0 ms | 1748 KB |
| random_02.txt | AC | 0 ms | 2120 KB |
| random_03.txt | AC | 0 ms | 1880 KB |
| random_04.txt | AC | 1 ms | 2120 KB |
| random_05.txt | AC | 1 ms | 1948 KB |
| random_06.txt | AC | 0 ms | 1848 KB |
| random_07.txt | AC | 0 ms | 2000 KB |
| random_08.txt | AC | 1 ms | 2248 KB |
| random_09.txt | AC | 1 ms | 2528 KB |
| random_10.txt | AC | 1 ms | 2536 KB |
| random_11.txt | AC | 1 ms | 2424 KB |
| random_12.txt | AC | 1 ms | 2428 KB |
| random_13.txt | AC | 1 ms | 2532 KB |
| random_14.txt | AC | 1 ms | 2548 KB |
| random_15.txt | AC | 1 ms | 2388 KB |
| random_16.txt | AC | 1 ms | 2388 KB |
| random_17.txt | AC | 0 ms | 1616 KB |
| random_18.txt | AC | 0 ms | 1624 KB |
| random_19.txt | AC | 0 ms | 1728 KB |
| sample_01.txt | AC | 0 ms | 1732 KB |
| sample_02.txt | AC | 0 ms | 1724 KB |