結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー siro53
提出日時 2023-08-12 15:12:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 1,937 ms
コンパイル使用メモリ 203,892 KB
最終ジャッジ日時 2025-02-16 05:53:55
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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