結果
| 問題 | No.1582 Vertexes vs Edges |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-08 12:06:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 573 bytes |
| 記録 | |
| コンパイル時間 | 605 ms |
| コンパイル使用メモリ | 72,760 KB |
| 実行使用メモリ | 9,088 KB |
| 最終ジャッジ日時 | 2024-07-01 12:29:14 |
| 合計ジャッジ時間 | 2,678 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 33 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int s[2];
vector<int> v[100009];
void dfs(int n, int p, int t)
{
s[t]++;
for (int i = 0; i < v[n].size(); i++) {
int tn = v[n][i];
if (tn == p) continue;
dfs(tn, n, 1 - t);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b; cin >> a >> b;
v[a].push_back(b); v[b].push_back(a);
}
dfs(1, 0, 0);
cout << min(s[0], s[1]) << '\n';
return 0;
}