結果
問題 |
No.3092 Tired Queen
|
ユーザー |
|
提出日時 | 2025-04-06 16:46:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,583 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 197,972 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-06 16:46:50 |
合計ジャッジ時間 | 7,149 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<vector<int>> ans(N, vector<int>(N)); if (N%2 == 1 && N != 3) cout << -1 << endl; else if (N%2 == 1){ cout << 1 << " " << 4 << " " << 8 << endl; cout << 6 << " " << 2 << " " << 3 << endl; cout << 7 << " " << 5 << " " << 9 << endl; } else { bool flag = true; int current_x = 0, current_y = 0; int cnt = 1; for (int i=0; i<N/2; i++){ for (int j=0; j<N/2; j++){ if (flag){ ans[current_x][current_y] = cnt; cnt++; ans[current_x+1][current_y+1] = cnt; cnt++; ans[current_x][current_y+1] = cnt; cnt++; ans[current_x+1][current_y] = cnt; cnt++; current_x += 2; } else { ans[current_x][current_y] = cnt; cnt++; ans[current_x-1][current_y+1] = cnt; cnt++; ans[current_x][current_y+1] = cnt; cnt++; ans[current_x-1][current_y] = cnt; cnt++; current_x -= 2; } } if (flag){ current_x -= 1; flag = false; } else { current_x += 1; flag = true; } current_y += 2; } for (auto v : ans){ for (auto e : v){ cout << e << " "; } cout << endl; } } }