Submission #1771104


Source Code Expand

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; Edg
int dp[SZ][2];
void dfs(int x,int f=0)
{
	int mi=-1;
	for esb(x,e,b) if(b!=f)
	{
		dfs(b,x), dp[x][1]+=dp[b][0];
		mi=max(mi,dp[b][1]-dp[b][0]);
	}
	dp[x][0]=dp[x][1]+mi+1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i)
		scanf("%d%d",&a,&b),adde(a,b);
	dfs(1);
	if(max(dp[1][0],dp[1][1])*2==n)
		puts("Second");
	else puts("First");
}

Submission Info

Submission Time
Task D - Black and White Tree
User fjzzq2002
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1437 Byte
Status AC
Exec Time 24 ms
Memory 9216 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:49:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a,&b),adde(a,b);
                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 39
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 23 ms 9216 KB
in10.txt AC 23 ms 9216 KB
in11.txt AC 24 ms 9216 KB
in12.txt AC 4 ms 6528 KB
in13.txt AC 24 ms 9216 KB
in14.txt AC 24 ms 9216 KB
in15.txt AC 24 ms 9216 KB
in16.txt AC 24 ms 9216 KB
in17.txt AC 23 ms 9216 KB
in18.txt AC 24 ms 9216 KB
in19.txt AC 24 ms 9216 KB
in2.txt AC 23 ms 9216 KB
in20.txt AC 24 ms 9216 KB
in21.txt AC 24 ms 9216 KB
in22.txt AC 23 ms 9216 KB
in23.txt AC 24 ms 9216 KB
in24.txt AC 23 ms 9216 KB
in25.txt AC 24 ms 9216 KB
in26.txt AC 24 ms 9216 KB
in27.txt AC 24 ms 9216 KB
in28.txt AC 3 ms 6400 KB
in29.txt AC 24 ms 9216 KB
in3.txt AC 23 ms 9216 KB
in30.txt AC 23 ms 9216 KB
in31.txt AC 24 ms 9216 KB
in32.txt AC 24 ms 9216 KB
in33.txt AC 24 ms 9216 KB
in4.txt AC 24 ms 9216 KB
in5.txt AC 23 ms 9216 KB
in6.txt AC 24 ms 9216 KB
in7.txt AC 24 ms 9216 KB
in8.txt AC 24 ms 9216 KB
in9.txt AC 24 ms 9216 KB
sample1.txt AC 3 ms 6400 KB
sample2.txt AC 3 ms 6400 KB
sample3.txt AC 3 ms 6400 KB