Submission #73999339
Source Code Expand
Copy
#include <stdio.h>int masu[128][128];int main(void) {int N;int k, i, j, r, c;if (scanf("%d", &N) != 1) return 1;masu[r = 0][c = (N - 1) / 2] = 1;for (k = 2; k <= N * N; k++) {int nr = (r - 1 + N) % N, nc = (c + 1) % N;if (masu[nr][nc] == 0) {masu[r = nr][c = nc] = k;} else {masu[r = (r + 1) % N][c] = k;}}for (i = 0; i < N; i++) {for (j = 0; j < N; j++) {printf(" %d" + !j, masu[i][j]);}
#include <stdio.h>
int masu[128][128];
int main(void) {
int N;
int k, i, j, r, c;
if (scanf("%d", &N) != 1) return 1;
masu[r = 0][c = (N - 1) / 2] = 1;
for (k = 2; k <= N * N; k++) {
int nr = (r - 1 + N) % N, nc = (c + 1) % N;
if (masu[nr][nc] == 0) {
masu[r = nr][c = nc] = k;
} else {
masu[r = (r + 1) % N][c] = k;
}
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
printf(" %d" + !j, masu[i][j]);
}
putchar('\n');
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magic Square |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 200 |
| Code Size | 495 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 1860 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 0 ms | 1624 KiB |
| 00_sample_01.txt | AC | 0 ms | 1700 KiB |
| 01_test_00.txt | AC | 0 ms | 1644 KiB |
| 01_test_01.txt | AC | 0 ms | 1680 KiB |
| 01_test_02.txt | AC | 0 ms | 1544 KiB |
| 01_test_03.txt | AC | 0 ms | 1620 KiB |
| 01_test_04.txt | AC | 1 ms | 1608 KiB |
| 01_test_05.txt | AC | 1 ms | 1736 KiB |
| 01_test_06.txt | AC | 1 ms | 1648 KiB |
| 01_test_07.txt | AC | 1 ms | 1828 KiB |
| 01_test_08.txt | AC | 1 ms | 1860 KiB |
| 01_test_09.txt | AC | 1 ms | 1732 KiB |
| 01_test_10.txt | AC | 1 ms | 1652 KiB |