Submission #1750843


Source Code Expand

#include<bits/stdc++.h>
#define N 200005
using namespace std;
int head[N],ver[N],nxt[N],tot;
void add(int a,int b)
{
	tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;return ;
}
int g[N];
bool flag,n;
void dfs(int x,int f)
{
	g[x]=0;
	for(int i=head[x];i;i=nxt[i])
	{
		if(ver[i]==f)continue;
		dfs(ver[i],x);
		if(!g[ver[i]])
		{
			if(!g[x])g[x]=1;
			else flag=1; 
		}
	}
}
int main()
{
	scanf("%d",&n)
	
		tot=0;
		int t1,t2;flag=0;
		for(int i=1;i<n;i++)
		{
			scanf("%d%d",&t1,&t2);
			add(t1,t2);add(t2,t1);
		}
		dfs(1,-1);
		for(int i=1;i<=n;i++)head[i]=0;
		if(flag||!g[1])puts("First");
		else puts("Second");
	
	return 0;	
} 

Submission Info

Submission Time
Task D - Black and White Tree
User SD_le
Language C++14 (GCC 5.4.1)
Score 0
Code Size 676 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:15: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘bool*’ [-Wformat=]
  scanf("%d",&n)
               ^
./Main.cpp:29:3: error: expected ‘;’ before ‘tot’
   tot=0;
   ^
./Main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   tot=0;
        ^
./Main.cpp:33:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d",&t1,&t2);
                         ^