結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-19 20:25:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,759 bytes |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 172,140 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 10:21:26 |
| 合計ジャッジ時間 | 2,766 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 RE * 1 |
ソースコード
#include "bits/stdc++.h"
#pragma warning(disable : 4996)
typedef long long ll;
#define all(x) (x).begin(), (x).end() // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))
#ifdef _MSC_FULL_VER // デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
if (false) \
cout
#define debug() if (false)
#define check(x) \
if (false) \
cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
if (false) \
cout << "☆" << x << endl
#endif
using namespace std;
// #define int long long;
double dist(double x1, double y1, double x2, double y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2)
{
return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
signed main()
{
ll n;
cin >> n;
ll x = 0,y = 0;
ll dir = 0;
vector<vector<ll>> vv(n,vector<ll>(n,-1));
rep(i,n*n){
vv[x][y] = i+1;
if(dir == 0){
x++;
if(x == n-1 || vv[x+1][y] != -1){
dir = 1;
}
}
else if(dir == 1){
y++;
if(y == n-1 || vv[x][y+1] != -1){
dir = 2;
}
}
else if(dir == 2){
x--;
if(x == 0 || vv[x-1][y] != -1){
dir = 3;
}
}
else if(dir == 3){
y--;
if(y == 0 || vv[x][y-1] != -1){
dir = 0;
}
}
}
rep(i,n){
rep(j,n){
if(vv[j][i] < 10) cout << "00" << vv[j][i] << " ";
else if(vv[j][i] < 100) cout << 0 << vv[j][i] << " ";
else cout << vv[j][i] << " ";
}
cout << endl;
}
}