結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-23 23:22:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 623 bytes |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 170,316 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 10:25:18 |
| 合計ジャッジ時間 | 2,306 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
int in_range( int n, int x, int y ){
return 0 <= x and x < n and 0 <= y and y < n;
}
signed main(){
int N; cin >> N;
vector< vector< int > > G( N, vector< int >( N ) );
int x = 0, y = 0, d = 0;
for( int i = 1; i <= N * N; ++i ){
G[ x ][ y ] = i;
if( not in_range( N, x + dx[ d ], y + dy[ d ] ) )
++d, d %= 4;
x += dx[ d ], y += dy[ d ];
}
for( int i = 0; i < N; ++i )
for( int j = 0; j < N; ++j )
printf( "%03d%c", G[ i ][ j ], " \n"[ j + 1 == N ] );
return 0;
}