結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー m_99m_99
提出日時 2023-08-12 13:36:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 3,854 ms
コンパイル使用メモリ 228,888 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 03:36:30
合計ジャッジ時間 5,599 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 56 ms
5,376 KB
testcase_04 AC 8 ms
5,376 KB
testcase_05 AC 40 ms
5,376 KB
testcase_06 AC 36 ms
5,376 KB
testcase_07 AC 44 ms
5,376 KB
testcase_08 AC 36 ms
5,376 KB
testcase_09 AC 53 ms
5,376 KB
testcase_10 AC 58 ms
5,376 KB
testcase_11 AC 49 ms
5,376 KB
testcase_12 AC 33 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 31 ms
5,376 KB
testcase_15 AC 40 ms
5,376 KB
testcase_16 AC 61 ms
5,376 KB
testcase_17 AC 21 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 45 ms
5,376 KB
testcase_21 AC 20 ms
5,376 KB
testcase_22 AC 24 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int n,m;
	cin>>n>>m;
	
	dsu D(n*2);
	vector<int> a(m),b(m);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	
	rep(i,m){
		D.merge(a[i],b[i]);
	}
	int ans = 0;
	rep(i,n*2){
		if(D.leader(i)==i){
			ans += D.size(i)%2;
		}
	}
	cout<<ans/2<<endl;
		
	
	return 0;
}
0