結果
| 問題 |
No.763 Noelちゃんと木遊び
|
| コンテスト | |
| ユーザー |
miwawa
|
| 提出日時 | 2024-02-23 14:09:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 569 bytes |
| コンパイル時間 | 1,140 ms |
| コンパイル使用メモリ | 91,968 KB |
| 実行使用メモリ | 16,768 KB |
| 最終ジャッジ日時 | 2025-03-22 10:42:54 |
| 合計ジャッジ時間 | 3,604 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#define rep(i,a,b) for(i=a;i<b;i++)
using namespace std;
using Graph = vector<vector<int>>;
vector<int> a[100001];
vector<bool> tomato;
void f(int v,int p){
bool topi=false;
for(auto ch:a[v]){
if(ch==p)continue;
f(ch,v);
if(tomato[ch])topi=true;
}
if(!topi)tomato[v]=true;
}
int main() {
int n,aa,b,i;
cin>>n;
rep(i,0,n-1){
cin>>aa>>b;
a[aa].push_back(b);
a[b].push_back(aa);
}
tomato.assign(n,false);
f(1,0);
int h=0;
rep(i,0,n+1){
if(tomato[i])h++;
}
cout<<h<<endl;
}
miwawa