Submission #1736033
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int maxn=2e5+10; int n,deg[maxn]; int tote,FIR[maxn],TO[maxn],NEXT[maxn]; bool vis[maxn]; queue<int> q; void addedge(int u,int v) { TO[++tote]=v; NEXT[tote]=FIR[u]; FIR[u]=tote; } int main() { #ifdef h10 freopen("D.in","r",stdin); freopen("D.out","w",stdout); #endif int i,u,v; scanf("%d",&n); if (n&1) {puts("First"); return 0;} for (i=1;i<n;i++) { scanf("%d%d",&u,&v); addedge(u,v); addedge(v,u); deg[u]++; deg[v]++; } for (i=1;i<=n;i++) if (deg[i]==1) q.push(i); vis[0]=1; for (i=1;i<=n>>1;i++) { u=v=0; while (vis[u]) u=q.front(),q.pop(); for (int p=FIR[u];p;p=NEXT[p]) { v=TO[p]; if (!vis[v]) break; } if (vis[v]) {puts("First"); return 0;} vis[u]=vis[v]=1; for (int p=FIR[v];p;p=NEXT[p]) { u=TO[p]; if (!vis[u]&&(--deg[u])==1) q.push(u); } } puts("Second"); }
Submission Info
Submission Time | |
---|---|
Task | D - Black and White Tree |
User | h10 |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 935 Byte |
Status | AC |
Exec Time | 25 ms |
Memory | 2944 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:25:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&u,&v); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 20 ms | 2944 KB |
in10.txt | AC | 20 ms | 2944 KB |
in11.txt | AC | 24 ms | 2816 KB |
in12.txt | AC | 3 ms | 512 KB |
in13.txt | AC | 25 ms | 2816 KB |
in14.txt | AC | 24 ms | 2816 KB |
in15.txt | AC | 24 ms | 2816 KB |
in16.txt | AC | 24 ms | 2816 KB |
in17.txt | AC | 25 ms | 2816 KB |
in18.txt | AC | 25 ms | 2816 KB |
in19.txt | AC | 24 ms | 2816 KB |
in2.txt | AC | 20 ms | 2944 KB |
in20.txt | AC | 24 ms | 2816 KB |
in21.txt | AC | 20 ms | 2944 KB |
in22.txt | AC | 20 ms | 2944 KB |
in23.txt | AC | 21 ms | 2816 KB |
in24.txt | AC | 21 ms | 2816 KB |
in25.txt | AC | 22 ms | 2816 KB |
in26.txt | AC | 23 ms | 2816 KB |
in27.txt | AC | 22 ms | 2816 KB |
in28.txt | AC | 1 ms | 256 KB |
in29.txt | AC | 1 ms | 256 KB |
in3.txt | AC | 21 ms | 2944 KB |
in30.txt | AC | 1 ms | 256 KB |
in31.txt | AC | 24 ms | 2816 KB |
in32.txt | AC | 23 ms | 2816 KB |
in33.txt | AC | 23 ms | 2816 KB |
in4.txt | AC | 21 ms | 2944 KB |
in5.txt | AC | 21 ms | 2944 KB |
in6.txt | AC | 1 ms | 256 KB |
in7.txt | AC | 20 ms | 2944 KB |
in8.txt | AC | 20 ms | 2944 KB |
in9.txt | AC | 20 ms | 2944 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |