Submission #49083116
Source Code Expand
/**
* @the_hyp0cr1t3
* 06.01.2024 17:41
**/
#include <bits/stdc++.h>
int dx[] = {0, +1, 0, -1};
int dy[] = {+1, 0, -1, 0};
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n;
std::cin >> n;
std::vector<std::vector<int>> ans(n, std::vector<int>(n, -1));
int i = 0, j = 0, k = 0, z = 1;
for (int _ = 1; _ < n * n; _++) {
ans[i][j] = z++;
int x, y;
while (true) {
x = i + dx[k];
y = j + dy[k];
if (0 <= x and x < n and 0 <= y and y < n and ans[x][y] == -1)
break;
k = (k + 1) % 4;
}
i = x;
j = y;
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (i == n / 2 and j == n / 2)
std::cout << 'T' << ' ';
else
std::cout << ans[i][j] << " \n"[j + 1 == n];
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Loong and Takahashi |
| User | the_hyp0cr1t3 |
| Language | C++ 20 (gcc 12.2) |
| Score | 350 |
| Code Size | 932 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3584 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.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, random_20.txt, random_21.txt, sample_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| random_01.txt | AC | 1 ms | 3464 KiB |
| random_02.txt | AC | 1 ms | 3324 KiB |
| random_03.txt | AC | 1 ms | 3472 KiB |
| random_04.txt | AC | 1 ms | 3400 KiB |
| random_05.txt | AC | 1 ms | 3448 KiB |
| random_06.txt | AC | 1 ms | 3476 KiB |
| random_07.txt | AC | 1 ms | 3420 KiB |
| random_08.txt | AC | 1 ms | 3404 KiB |
| random_09.txt | AC | 1 ms | 3584 KiB |
| random_10.txt | AC | 1 ms | 3388 KiB |
| random_11.txt | AC | 1 ms | 3472 KiB |
| random_12.txt | AC | 1 ms | 3420 KiB |
| random_13.txt | AC | 1 ms | 3484 KiB |
| random_14.txt | AC | 1 ms | 3476 KiB |
| random_15.txt | AC | 1 ms | 3424 KiB |
| random_16.txt | AC | 1 ms | 3448 KiB |
| random_17.txt | AC | 1 ms | 3496 KiB |
| random_18.txt | AC | 1 ms | 3336 KiB |
| random_19.txt | AC | 1 ms | 3452 KiB |
| random_20.txt | AC | 1 ms | 3396 KiB |
| random_21.txt | AC | 1 ms | 3336 KiB |
| sample_01.txt | AC | 1 ms | 3328 KiB |