結果

問題 No.2824 Lights Up! (Grid Edition)
ユーザー 🦠みどりむし🦠みどりむし
提出日時 2024-06-17 11:58:52
言語 C++23
(gcc 12.3.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 23 ms
6,940 KB
testcase_05 AC 23 ms
6,940 KB
testcase_06 AC 22 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 23 ms
6,944 KB
testcase_09 AC 22 ms
6,944 KB
testcase_10 AC 23 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 22 ms
6,940 KB
testcase_13 WA -
testcase_14 AC 23 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 17 ms
6,944 KB
testcase_17 WA -
testcase_18 AC 23 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 6 ms
6,944 KB
testcase_21 AC 16 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 9 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,944 KB
testcase_29 WA -
testcase_30 AC 3 ms
6,944 KB
testcase_31 WA -
testcase_32 AC 3 ms
6,944 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 WA -
testcase_36 AC 2 ms
6,940 KB
testcase_37 WA -
testcase_38 AC 2 ms
6,940 KB
testcase_39 WA -
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 AC 2 ms
6,944 KB
testcase_43 WA -
testcase_44 AC 2 ms
6,944 KB
testcase_45 WA -
testcase_46 AC 2 ms
6,940 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
6,944 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
6,944 KB
testcase_55 WA -
testcase_56 AC 2 ms
6,944 KB
testcase_57 AC 2 ms
6,940 KB
testcase_58 AC 1 ms
6,940 KB
testcase_59 WA -
testcase_60 AC 2 ms
6,940 KB
testcase_61 WA -
testcase_62 AC 2 ms
6,944 KB
testcase_63 WA -
testcase_64 AC 2 ms
6,944 KB
testcase_65 AC 2 ms
6,944 KB
testcase_66 AC 2 ms
6,940 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 2 ms
6,944 KB
testcase_70 AC 2 ms
6,944 KB
testcase_71 AC 2 ms
6,944 KB
testcase_72 AC 2 ms
6,940 KB
testcase_73 AC 2 ms
6,944 KB
testcase_74 AC 2 ms
6,944 KB
testcase_75 AC 2 ms
6,944 KB
testcase_76 AC 2 ms
6,940 KB
testcase_77 AC 2 ms
6,940 KB
testcase_78 AC 2 ms
6,940 KB
testcase_79 AC 2 ms
6,940 KB
testcase_80 AC 2 ms
6,940 KB
testcase_81 AC 2 ms
6,940 KB
testcase_82 AC 2 ms
6,940 KB
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 AC 2 ms
6,940 KB
testcase_89 AC 2 ms
6,940 KB
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 AC 2 ms
6,940 KB
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:31:5: warning: control reaches end of non-void function [-Wreturn-type]
   31 |     };
      |     ^

ソースコード

diff #

#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); }
0