結果
問題 |
No.3092 Tired Queen
|
ユーザー |
![]() |
提出日時 | 2025-04-06 16:06:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 2,015 ms |
コンパイル使用メモリ | 198,248 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2025-04-06 16:06:57 |
合計ジャッジ時間 | 6,267 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
#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/2+1)*N-(4*(i/2+1)*(i/2+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{ //cout<<x<<' '<<y<<endl; 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; } }