Submission #71661335
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(arg) cout << "[" << #arg << "]: " << arg << endl
#else
#define debug(arg) 42
#endif
using llu = uint64_t;
using ll = int64_t;
#define vec vector
#define pb push_back
#define all(n) begin(n), end(n)
void solv() {
int n; cin >> n;
vec<vec<int>> mat(n, vec<int>(n));
int r = 0, c = (n - 1)/2;
mat[r][c] = 1;
for (int i = 1; i < n*n; ++i) {
int nr, nc;
nr = (n + r - 1)%n, nc = (c + 1)%n;
if (mat[nr][nc]) nr = (r + 1)%n, nc = c;
r = nr, c = nc;
mat[r][c] = i + 1;
}
for (auto &v : mat) {
for (auto &i : v) cout << i << ' ';
cout << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int t = 1;
//cin >> t;
while (t--) solv();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magic Square |
| User | fisher199 |
| Language | C++23 (Clang 21.1.0) |
| Score | 200 |
| Code Size | 802 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 2984 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 | 2 ms | 2860 KiB |
| 00_sample_01.txt | AC | 1 ms | 2812 KiB |
| 01_test_00.txt | AC | 1 ms | 2788 KiB |
| 01_test_01.txt | AC | 1 ms | 2792 KiB |
| 01_test_02.txt | AC | 1 ms | 2984 KiB |
| 01_test_03.txt | AC | 1 ms | 2788 KiB |
| 01_test_04.txt | AC | 1 ms | 2844 KiB |
| 01_test_05.txt | AC | 1 ms | 2928 KiB |
| 01_test_06.txt | AC | 1 ms | 2960 KiB |
| 01_test_07.txt | AC | 1 ms | 2736 KiB |
| 01_test_08.txt | AC | 2 ms | 2812 KiB |
| 01_test_09.txt | AC | 2 ms | 2852 KiB |
| 01_test_10.txt | AC | 2 ms | 2848 KiB |