Submission #71660604
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n, a[105][105];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
int it = 1, h = 1, l = n / 2 + 1;
a[h][l] = it;
while(it < n * n) {
if(a[(h + n - 2) % n + 1][(l) % n + 1]) h = h % n + 1;
else h = (h + n - 2) % n + 1, l = l % n + 1;
a[h][l] = ++ it;
}
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= n; j ++) {
cout << a[i][j] << ' ';
}
cout << '\n';
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magic Square |
| User | WangYueHeng |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 494 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 3748 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 | 1 ms | 3640 KiB |
| 00_sample_01.txt | AC | 1 ms | 3564 KiB |
| 01_test_00.txt | AC | 1 ms | 3548 KiB |
| 01_test_01.txt | AC | 1 ms | 3712 KiB |
| 01_test_02.txt | AC | 1 ms | 3564 KiB |
| 01_test_03.txt | AC | 1 ms | 3692 KiB |
| 01_test_04.txt | AC | 1 ms | 3700 KiB |
| 01_test_05.txt | AC | 1 ms | 3576 KiB |
| 01_test_06.txt | AC | 2 ms | 3676 KiB |
| 01_test_07.txt | AC | 2 ms | 3668 KiB |
| 01_test_08.txt | AC | 2 ms | 3748 KiB |
| 01_test_09.txt | AC | 2 ms | 3676 KiB |
| 01_test_10.txt | AC | 2 ms | 3676 KiB |