結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
|
提出日時 | 2016-07-22 22:39:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 75,476 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-06 09:06:17 |
合計ジャッジ時間 | 4,258 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 25 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> using namespace std; const vector<int> dx = {1, 0, -1, 0}; const vector<int> dy = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<vector<int>> a(n, vector<int>(n, -1)); int x = 0; int y = 0; int dir = 0; int nx, ny; int z = 1; while (z <= n*n) { while (0 <= x && x < n && 0 <= y && y < n && a[y][x] == -1) { a[y][x] = z; x = (x + dx[dir]) % 4; y = (y + dy[dir]) % 4; z++; } x = (x + 4 - dx[dir]) % 4; y = (y + 4 - dy[dir]) % 4; dir = (dir + 1) % 4; x = (x + dx[dir]) % 4; y = (y + dy[dir]) % 4; } for (auto aa : a) { for (auto aaa : aa) { printf("%03d ", aaa); } printf("\n"); } return 0; }