結果
問題 |
No.2418 情報通だよ!Nafmoくん
|
ユーザー |
![]() |
提出日時 | 2023-08-12 13:53:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 1,660 ms |
コンパイル使用メモリ | 171,476 KB |
実行使用メモリ | 12,120 KB |
最終ジャッジ日時 | 2024-11-14 12:22:26 |
合計ジャッジ時間 | 3,194 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++) #define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--) #define all(v) v.begin(), v.end() typedef long long ll; template <class T> using V = vector<T>; template <class T> using VV = vector<V<T>>; V<int> G[200010]; V<bool> used(200010); int nc = 0; void f(int k) { used[k] = 1; nc++; rep(i,0,G[k].size()) { int to = G[k][i]; if (used[to]) continue; f(to); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); constexpr char endl = '\n'; int n,m; cin >> n >> m; rep(i,0,m) { int a,b; cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } int cnt = 0; rep(i,1,2*n+1) { if (!used[i]) { nc = 0; f(i); cnt += nc % 2; } } cout << cnt / 2 << endl; return 0; }