結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー siro53siro53
提出日時 2023-08-12 15:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 210,208 KB
実行使用メモリ 14,788 KB
最終ジャッジ日時 2024-04-30 08:24:18
合計ジャッジ時間 4,382 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 74 ms
13,044 KB
testcase_04 AC 21 ms
12,528 KB
testcase_05 AC 45 ms
6,940 KB
testcase_06 AC 51 ms
12,696 KB
testcase_07 AC 47 ms
6,940 KB
testcase_08 AC 57 ms
14,788 KB
testcase_09 AC 58 ms
7,424 KB
testcase_10 AC 73 ms
11,848 KB
testcase_11 AC 62 ms
11,264 KB
testcase_12 AC 44 ms
10,000 KB
testcase_13 AC 21 ms
6,940 KB
testcase_14 AC 38 ms
7,948 KB
testcase_15 AC 39 ms
6,940 KB
testcase_16 AC 71 ms
9,240 KB
testcase_17 AC 20 ms
6,944 KB
testcase_18 AC 41 ms
11,152 KB
testcase_19 AC 17 ms
11,784 KB
testcase_20 AC 44 ms
6,940 KB
testcase_21 AC 26 ms
6,940 KB
testcase_22 AC 25 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  atcoder::dsu uf(N*2);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.merge(a, b);
  }
  auto gs = uf.groups();
  int ans = 0;
  for(const auto& g : gs) ans += (int)g.size() % 2;
  assert(ans % 2 == 0);
  ans /= 2;
  cout << ans << endl;
}
0