結果

問題 No.2277 Honest or Dishonest ?
ユーザー miscalcmiscalc
提出日時 2023-04-19 23:52:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 882 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 204,120 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-25 18:46:48
合計ジャッジ時間 6,963 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 38 ms
6,948 KB
testcase_13 WA -
testcase_14 AC 46 ms
6,944 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 60 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 82 ms
7,740 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 38 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 36 ms
6,944 KB
testcase_31 AC 61 ms
8,448 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 90 ms
10,240 KB
testcase_35 WA -
testcase_36 AC 53 ms
7,808 KB
testcase_37 AC 85 ms
8,576 KB
testcase_38 AC 18 ms
6,940 KB
testcase_39 AC 27 ms
6,948 KB
testcase_40 WA -
testcase_41 AC 97 ms
10,752 KB
testcase_42 AC 64 ms
8,704 KB
testcase_43 AC 100 ms
11,520 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 103 ms
11,776 KB
testcase_50 AC 104 ms
11,648 KB
testcase_51 AC 108 ms
11,520 KB
testcase_52 AC 110 ms
11,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;

int main()
{
  int N, Q;
  cin >> N >> Q;
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < Q; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G.at(a).push_back({b, c});
    G.at(b).push_back({a, c});
  }

  mint ans = 1;
  vector<int> colors(N, -1);
  auto dfs = [&](auto self, int v) -> void
  {
    for (auto [nv, d] : G.at(v))
    {
      int new_color = colors.at(v) ^ d;
      if (colors.at(nv) == -1)
      {
        colors.at(nv) = new_color;
        self(self, nv);
      }
      else if (colors.at(nv) != new_color)
        ans *= 0;
    }
  };
  for (int v = 0; v < N; v++)
  {
    if (colors.at(v) == -1)
    {
      ans *= 2;
      colors.at(v) = 0;
      dfs(dfs, v);
    }
  }
  cout << ans.val() << endl;
}
0