結果
問題 |
No.2824 Lights Up! (Grid Edition)
|
ユーザー |
|
提出日時 | 2024-07-25 08:41:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,207 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 201,348 KB |
最終ジャッジ日時 | 2025-02-23 17:58:55 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 87 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++){ cin >> S[i]; } auto op = [&](int r, int c){ S[r][c] ^= '.' ^ '#'; S[(N + r - 1) % N][c] ^= '.' ^ '#'; S[r][(N + c - 1) % N] ^= '.' ^ '#'; S[(N + r - 1) % N][(N + c - 1) % N] ^= '.' ^ '#'; }; vector<pair<int, int>> ans; for (int i = 1; i < N; i++){ for (int j = 1; j < N; j++){ if (S[i - 1][j - 1] == '#'){ ans.push_back(make_pair(i, j)); op(i, j); op(i, 0); op(0, j); } } } for (int i = 1; i < N; i += 2){ if (S[i][0] == '#'){ for (int j = 0; j < N; j++){ ans.push_back(make_pair(i, j)); op(i, j); op(i, 0); op(0, j); } } if (S[0][i] == '#'){ for (int j = 0; j < N; j++){ ans.push_back(make_pair(j, i)); op(j, i); op(j, 0); op(0, i); } } } if (S[0][0] == '#'){ ans.push_back(make_pair(0, 0)); op(0, 0); } bool ok = true; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (S[i][j] == '#'){ ok = false; } } } if (ok){ cout << ans.size() << endl; for (auto [R, C] : ans){ cout << R << ' ' << C << endl; } } else { cout << -1 << endl; } }