結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 82 ms
12,544 KB
testcase_04 AC 12 ms
8,192 KB
testcase_05 AC 56 ms
7,936 KB
testcase_06 AC 53 ms
10,880 KB
testcase_07 AC 60 ms
7,552 KB
testcase_08 AC 53 ms
12,032 KB
testcase_09 AC 75 ms
9,344 KB
testcase_10 AC 85 ms
11,900 KB
testcase_11 AC 74 ms
11,008 KB
testcase_12 AC 48 ms
9,216 KB
testcase_13 AC 24 ms
5,760 KB
testcase_14 AC 43 ms
8,064 KB
testcase_15 AC 45 ms
5,376 KB
testcase_16 AC 89 ms
10,880 KB
testcase_17 AC 24 ms
5,376 KB
testcase_18 AC 43 ms
9,600 KB
testcase_19 AC 9 ms
7,552 KB
testcase_20 AC 49 ms
5,376 KB
testcase_21 AC 28 ms
6,528 KB
testcase_22 AC 31 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(int i = 0; i < (int)(n); ++i)
#define rep2(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep3(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep4(i, a, b, c) for(int i = (a); i < (int)(b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u16 = uint16_t;
int main(){
	int N,M;
	cin >> N >> M;
	vector<vector<int>> graph(2*N);
	rep(i,M){
		int a,b;
		cin >> a >> b;
		--a;--b;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}
	vector<int> ccid(2*N, -1);
	int ccn = 0;
	auto dfs = [&](auto f, int v)->void{
		if(ccid.at(v) != -1)return;
		ccid.at(v) = ccn;
		for(auto nv : graph.at(v)){
			f(f, nv);
		}
	};
	rep(i,2*N){
		if(ccid[i] != -1)continue;
		dfs(dfs, i);
		ccn++;
	}
	vector<int> groupSize(2*N,0);
	rep(i,2*N){
		groupSize.at(ccid.at(i))++;
	}
	int ans = 0;
	rep(i,2*N){
		if(groupSize.at(i) % 2 == 1)ans++;
	}
	cout << ans/2 << endl;
}
0