結果
| 問題 |
No.1582 Vertexes vs Edges
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-02 21:46:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 373 bytes |
| コンパイル時間 | 589 ms |
| コンパイル使用メモリ | 70,528 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2024-06-29 11:17:56 |
| 合計ジャッジ時間 | 3,251 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 33 |
コンパイルメッセージ
main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int>G[1<<17];
int cnt[2];
void dfs(int u,int p,int c)
{
cnt[c]++;
for(int v:G[u])if(v!=p)dfs(v,u,1-c);
}
main()
{
cin>>N;
for(int i=1;i<N;i++)
{
int a,b;cin>>a>>b;a--,b--;
G[a].push_back(b);
G[b].push_back(a);
}
dfs(0,-1,0);
int ans=cnt[0];
if(ans>cnt[1])ans=cnt[1];
cout<<ans<<endl;
}