結果
問題 |
No.3092 Tired Queen
|
ユーザー |
![]() |
提出日時 | 2025-04-06 16:01:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 771 bytes |
コンパイル時間 | 1,997 ms |
コンパイル使用メモリ | 198,520 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-04-06 16:02:03 |
合計ジャッジ時間 | 12,069 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 2 RE * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N; cin>>N; vector<vector<int>> A(N,vector<int>(N,-1)); int now = 1; for(int i=0;i<N;i+=2){ int x = i, y = i; bool p = true; while(now <= 4*(i+1)*N-(4*(i+1)*(i+1))){ A[x][y] = now; now++; if(p){ if(x <= y){ if(y != 0 && A[x][y-1] == -1) y--; else if(y != N-1 && A[x][y+1] == -1) y++; else x++; } else{ if(x != 0 && A[x-1][y] == -1) x--; else if(x != N-1 & A[x+1][y] == -1) x++; else y++; } } else swap(x,y); p ^= 1; } } A[N-1][N-1] = N*N; for(int i=0;i<N;i++){ for(int x:A[i]) cout<<x<<' '; cout<<endl; } }