結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
ku_material_ro
|
| 提出日時 | 2016-09-26 01:46:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,043 bytes |
| コンパイル時間 | 1,068 ms |
| コンパイル使用メモリ | 74,824 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-18 15:03:18 |
| 合計ジャッジ時間 | 3,043 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 17 RE * 7 |
ソースコード
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
string s;
int map[30][30] = {0};
string ans[30][30];
int n; cin >> n;
int vx[4] = { 1,0, -1, 0 };
int vy[4] = { 0,1, 0, -1 };
int x = 0;
int y = 0;
int i = 1;
int d = 0;
while (i<=n*n){
//cout << d <<"d"<< endl;
//cout << x << "x" << endl;
//cout << y << endl;
map[x][y] = i;
//cout << x << "x" << endl;
//cout << y << "y" << endl;
//cout << map[x + vx[d]][y + vy[d]] << "map[x + vx[d]][y + vy[d]]" << endl;
if (x+vx[d] == n || y+vy[d] == n || map[x + vx[d]][y + vy[d]] != 0){
d += 1;
if (d == 4){
d = 0;
}
}
//cout << d << "d" << endl;
x += vx[d];
y += vy[d];
i++;
}
for (int i = 0; i < n; i++){
for (int i1 = 0; i1 < n-1; i1++){
s = to_string(map[i1][i]);
string s1((3 - s.length()), '0');
ans[i1][i] = s1 + s;
cout << ans[i1][i] << " ";
}
s = to_string(map[n-1][i]);
string s1((3 - s.length()), '0');
ans[n-1][i] = s1 + s;
cout << ans[n - 1][i] << endl;
}
return 0;
}
ku_material_ro