結果
| 問題 |
No.2418 情報通だよ!Nafmoくん
|
| コンテスト | |
| ユーザー |
hatsuka_iwa
|
| 提出日時 | 2023-09-28 22:32:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 2,045 ms |
| コンパイル使用メモリ | 198,884 KB |
| 最終ジャッジ日時 | 2025-02-17 02:51:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, Odd = 0; cin >> N >> M;
vector<bool> seen(2 * N + 1);
vector<vector<int>> Graph(2 * N + 1);
for (int i = 0; i < M; i++) {
int A, B; cin >> A >> B;
Graph.at(A).push_back(B);
Graph.at(B).push_back(A);
}
for (int i = 1; i <= 2 * N; i++) {
if (seen.at(i)) continue;
int Count = 0;
auto DFS = [&](auto DFS, int x) {
if(seen.at(x)) return;
seen.at(x) = true;
Count++;
for (int to : Graph.at(x)) DFS(DFS, to);
};
DFS(DFS, i);
if (Count % 2) Odd++;
}
cout << Odd / 2 << endl;
}
hatsuka_iwa