結果
| 問題 |
No.2824 Lights Up! (Grid Edition)
|
| コンテスト | |
| ユーザー |
みどりむし🦠
|
| 提出日時 | 2024-06-17 11:58:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,048 bytes |
| コンパイル時間 | 1,368 ms |
| コンパイル使用メモリ | 136,108 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-26 20:31:24 |
| 合計ジャッジ時間 | 5,538 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 54 WA * 46 |
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:31:5: warning: control reaches end of non-void function [-Wreturn-type]
31 | };
| ^
ソースコード
#include <utility>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <valarray>
#include <vector>
#include <ranges>
signed main() {
int n; std::cin >> n;
std::vector pos(n, std::valarray<bool>(n));
std::valarray<bool> row(n), col(n);
for(const auto i : std::views::iota(0, n)) {
for(const auto j : std::views::iota(0, n)) {
char c; std::cin >> c;
if((pos[i][j] = (c == '#'))) row[i] ^= 1, col[j] ^= 1;
}
}
auto check_parity = [&](const bool even) {
if(even && row[0] != 0) return false;
if(row[0] != col[0]) return false;
for(const auto i : std::views::iota(1, n)) {
if(row[0] != row[i] or col[0] != col[i]) {
return false;
}
}
};
if(!check_parity(true)) {
std::cout << "-1\n";
return 0;
};
if(--n == 0) {
std::cout << "0\n";
return 0;
}
for(const auto i : std::views::iota(1, n)) {
for(const auto j : std::views::iota(0, n)) {
pos[i][j] ^= pos[i - 1][j];
}
}
for(const auto i : std::views::iota(0, n)) {
for(const auto j : std::views::iota(1, n)) {
pos[i][j] ^= pos[i][j - 1];
}
}
std::ranges::fill(row, 0);
std::ranges::fill(col, 0);
for(const auto i : std::views::iota(0, n)) {
for(const auto j : std::views::iota(0, n)) {
if(pos[i][j]) row[i] ^= 1, col[j] ^= 1;
}
}
if(n % 2 == 1 && !check_parity(false)) {
std::cout << "-1\n";
return 0;
}
std::vector<std::pair<int,int>> ans;
for(const int i : std::views::iota(0, n)) {
for(const int j : std::views::iota(0, n)) {
if(pos[i][j] ^ row[i] ^ col[j]) ans.emplace_back(i, j);
}
}
std::cout << ans.size() << "\n";
for(const auto [ i, j ] : ans) std::cout << i + 1 << " " << j + 1 << "\n";
}
__attribute__((constructor)) inline void fast_io() { std::ios::sync_with_stdio(false), std::cin.tie(nullptr); }
みどりむし🦠