結果

問題 No.2277 Honest or Dishonest ?
ユーザー SSRSSSRS
提出日時 2023-04-21 21:26:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 173,484 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-25 18:49:33
合計ジャッジ時間 6,456 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 84 ms
7,680 KB
testcase_04 AC 81 ms
8,576 KB
testcase_05 AC 30 ms
6,944 KB
testcase_06 AC 71 ms
6,940 KB
testcase_07 AC 55 ms
6,944 KB
testcase_08 AC 23 ms
6,940 KB
testcase_09 AC 51 ms
7,296 KB
testcase_10 AC 40 ms
6,940 KB
testcase_11 AC 19 ms
6,940 KB
testcase_12 AC 34 ms
6,940 KB
testcase_13 AC 80 ms
7,168 KB
testcase_14 AC 44 ms
6,940 KB
testcase_15 AC 26 ms
6,940 KB
testcase_16 AC 56 ms
6,940 KB
testcase_17 AC 28 ms
6,940 KB
testcase_18 AC 75 ms
8,576 KB
testcase_19 AC 79 ms
8,448 KB
testcase_20 AC 63 ms
7,168 KB
testcase_21 AC 57 ms
6,940 KB
testcase_22 AC 53 ms
6,940 KB
testcase_23 AC 79 ms
6,944 KB
testcase_24 AC 47 ms
6,940 KB
testcase_25 AC 58 ms
7,808 KB
testcase_26 AC 15 ms
6,940 KB
testcase_27 AC 38 ms
6,944 KB
testcase_28 AC 25 ms
6,944 KB
testcase_29 AC 40 ms
7,040 KB
testcase_30 AC 35 ms
6,940 KB
testcase_31 AC 61 ms
6,940 KB
testcase_32 AC 38 ms
6,940 KB
testcase_33 AC 77 ms
8,320 KB
testcase_34 AC 86 ms
8,192 KB
testcase_35 AC 9 ms
6,940 KB
testcase_36 AC 52 ms
6,940 KB
testcase_37 AC 81 ms
7,168 KB
testcase_38 AC 18 ms
6,944 KB
testcase_39 AC 26 ms
6,940 KB
testcase_40 AC 10 ms
6,944 KB
testcase_41 AC 93 ms
8,320 KB
testcase_42 AC 63 ms
6,940 KB
testcase_43 AC 101 ms
9,472 KB
testcase_44 AC 101 ms
9,600 KB
testcase_45 AC 99 ms
9,600 KB
testcase_46 AC 98 ms
9,472 KB
testcase_47 AC 97 ms
9,600 KB
testcase_48 AC 103 ms
9,728 KB
testcase_49 AC 98 ms
9,600 KB
testcase_50 AC 98 ms
9,472 KB
testcase_51 AC 97 ms
9,720 KB
testcase_52 AC 96 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < Q; i++){
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    E[A].push_back(make_pair(C, B));
    E[B].push_back(make_pair(C, A));
  }
  long long ans = 1;
  vector<int> C(N, -1);
  for (int i = 0; i < N; i++){
    if (C[i] == -1){
      C[i] = 0;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (pair<int, int> P : E[v]){
          int w = P.second;
          if (C[w] == -1){
            C[w] = C[v] ^ P.first;
            Q.push(w);
          } else if (C[w] != (C[v] ^ P.first)){
            ans = 0;
          }
        }
      }
      ans *= 2;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
0