結果
問題 | No.2112 All 2x2 are Equal |
ユーザー | eve__fuyuki |
提出日時 | 2024-05-21 14:14:49 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,263 bytes |
コンパイル時間 | 2,763 ms |
コンパイル使用メモリ | 210,728 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-12-20 18:12:13 |
合計ジャッジ時間 | 9,408 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 WA * 11 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int h, w; cin >> h >> w; cout << "Yes\n"; vector<vector<int>> ans(h, vector<int>(w, 0)); deque<int> dq; for (int i = 1; i <= h * w; i++) { dq.push_back(i); } for (int i = 0; i < (h % 2 && w % 2 ? h - 1 : h); i++) { for (int j = 0; j < w; j++) { if (i % 2 == 0) { ans[i][j] = dq.front(); dq.pop_front(); } else { ans[i][j] = dq.back(); dq.pop_back(); } if (i % 2 && j % 2) { swap(ans[i - 1][j], ans[i][j]); } } } if (h % 2 && w % 2) { int s = ans[0][0] + ans[0][1] + ans[1][0] + ans[1][1]; ans[h - 1][0] = dq.front(); for (int i = 1; i < w; i++) { ans[h - 1][i] = s - ans[h - 1][i - 1] - ans[h - 2][i - 1] - ans[h - 2][i]; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cout << ans[i][j] << " "; } cout << "\n"; } }