結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-02 16:50:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,671 bytes |
| コンパイル時間 | 1,809 ms |
| コンパイル使用メモリ | 172,140 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 01:28:04 |
| 合計ジャッジ時間 | 2,778 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fastcin {\
cin.tie(0);\
ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {
fastcin;
int n, c = 1, x = 0, y = 0;
cin >> n;
vvi b(n, vi(n));
for(x; x<n; x++) {
b[y][x] = c;
c++;
}
x--;
y++;
char m[] = {'d', 'l', 'u', 'r'};
int mn = 0;
rrep(i, n-1, 1) {
rep(j, 0, 2) {
if(m[mn]=='d') {
int tmp = y;
for(y; y<i+tmp; y++) {
b[y][x] = c;
c++;
}
y--;
x--;
mn++;
} else if(m[mn]=='l') {
int tmp = x;
for(x; x>tmp-i; x--) {
b[y][x] = c;
c++;
}
x++;
y--;
mn++;
} else if(m[mn]=='u') {
int tmp = y;
for(y; y>tmp-i; y--) {
b[y][x] = c;
c++;
}
y++;
x++;
mn++;
} else if(m[mn]=='r') {
int tmp = x;
for(x; x<i+tmp; x++) {
b[y][x] = c;
c++;
}
x--;
y++;
mn = 0;
}
}
}
rep(i, 0, n) {
rep(j, 0, n) {
printf("%03d ", b[i][j]);
}
printf("\n");
}
return 0;
}