Submission #2124277
Source Code Expand
#include<cstdio> #include<vector> using namespace std; const int maxn=100000; int n,f[maxn+10]; vector<int> g[maxn+10]; void dfs(int x,int fa){ bool isb=0; for(int i=0;i<g[x].size();++i){ int e=g[x][i]; if(e!=fa){ dfs(e,x); f[x]+=f[e]; if(!f[e]) if(!isb) isb=1; else ++f[x]; } } } int main(){ scanf("%d",&n); for(int i=1;i<n;++i){ int l,r; scanf("%d%d",&l,&r); ++l; ++r; g[l].push_back(r); g[r].push_back(l); } for(int i=1;i<=n;++i) if(g[i].size()>2){ dfs(i,0); printf("%d",f[i]); return 0; } printf("1"); }
Submission Info
Submission Time | |
---|---|
Task | E - Antennas on Tree |
User | nqiiii |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 557 Byte |
Status | AC |
Exec Time | 42 ms |
Memory | 10368 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:17:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:19:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int l,r; scanf("%d%d",&l,&r); ++l; ++r; ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 2560 KB |
0_01.txt | AC | 2 ms | 2560 KB |
0_02.txt | AC | 2 ms | 2560 KB |
1_00.txt | AC | 2 ms | 2560 KB |
1_01.txt | AC | 2 ms | 2560 KB |
1_02.txt | AC | 2 ms | 2560 KB |
1_03.txt | AC | 2 ms | 2560 KB |
1_04.txt | AC | 2 ms | 2560 KB |
1_05.txt | AC | 2 ms | 2560 KB |
1_06.txt | AC | 34 ms | 5760 KB |
1_07.txt | AC | 28 ms | 6136 KB |
1_08.txt | AC | 33 ms | 5760 KB |
1_09.txt | AC | 28 ms | 6136 KB |
1_10.txt | AC | 42 ms | 10368 KB |
1_11.txt | AC | 40 ms | 8064 KB |
1_12.txt | AC | 38 ms | 6400 KB |
1_13.txt | AC | 40 ms | 6144 KB |
1_14.txt | AC | 39 ms | 6144 KB |
1_15.txt | AC | 39 ms | 6144 KB |
1_16.txt | AC | 39 ms | 6144 KB |
1_17.txt | AC | 39 ms | 6272 KB |
1_18.txt | AC | 35 ms | 6400 KB |
1_19.txt | AC | 34 ms | 6656 KB |
1_20.txt | AC | 33 ms | 6528 KB |
1_21.txt | AC | 33 ms | 6400 KB |
1_22.txt | AC | 31 ms | 6136 KB |