結果

問題 No.1566 All Even
ユーザー ぷらぷら
提出日時 2021-06-26 13:36:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,570 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 206,380 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-07 16:31:56
合計ジャッジ時間 3,221 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    if(N >= 5) {
        if(M == 0) {
            cout << 3 << endl;
        }
        else {
            vector<int>x(M),y(M),z(M);
            for(int i = 0; i < M; i++) {
                cin >> x[i] >> y[i] >> z[i];
                x[i]--;
                y[i]--;
            }
            int ans = 0;
            for(int j = 0; j < 3; j++) {
                bool flag = true;
                for(int k = 0; k < M; k++) {
                    if(x[k]%3 == j) {
                        if(!z[k]) {
                            flag = false;
                        }
                    }
                    else {
                        if(z[k]) {
                            flag = false;
                        }
                    }
                }
                if(flag) {
                    ans++;
                }
            }
            cout << ans << endl;
        }
        return 0;
    }
    vector<int>x(M),y(M),z(M);
    for(int i = 0; i < M; i++) {
        cin >> x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }
    int ans = 0;
    for(int i = 0; i < (1 << N*N); i++) {
        vector<vector<int>>cnt(N,vector<int>(N));
        for(int j = 0; j < N*N; j++) {
            cnt[j/N][j%N] = 1 & (i >> j);
        }
        bool flag = true;
        for(int j = 0; j < M; j++) {
            if(cnt[x[j]][y[j]] != z[j]) {
                flag = false;
            }
        }
        for(int j = 0; j < N-1; j++) {
            for(int k = 0; k < N-1; k++) {
                int res = 0;
                res += cnt[j][k];
                res += cnt[j][k+1];
                res += cnt[j+1][k];
                res += cnt[j+1][k+1];
                if(res%2 != 0) {
                    flag = false;
                }
            }
        }
        for(int j = 0; j < N-2; j++) {
            for(int k = 0; k < N-2; k++) {
                int res = 0;
                for(int l = 0; l <= 2; l++) {
                    for(int m = 0; m <= 2; m++) {
                        res += cnt[j+l][k+m];
                    }
                }
                if(res%2 != 1) {
                    flag = false;
                }
            }
        }
        if(flag) {
            ans++;
            for(int j = 0; j < N; j++) {
                for(int k = 0; k < N; k++) {
                    cout << cnt[j][k] << " ";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    cout << ans << endl;
}
0