AtCoder Grand Contest 014

Submission #1569780

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,ok;
vector<int>edge[100005];
int d[100005],num;
void dfs(int v,int u,int dd){
	rep(i,edge[v].size()){
		if(edge[v][i]==u)continue;
		dfs(edge[v][i],v,1-dd);d[v]+=d[edge[v][i]];
	}
	d[v]+=dd?1:-1; if(abs(d[v])>=2) ok = 1;
}
int main(){
	cin>>n; if(n%2==1){puts("First"); return 0;}
	rep(i,n-1){
		int a,b;cin>>a>>b;edge[a].pb(b);edge[b].pb(a);
	}
	dfs(1,-1,0);
	puts(ok?"First":"Second");
}

Submission

Task問題 D - Black and White Tree
User nameユーザ名 高垣楓
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 900
Source lengthソースコード長 1031 Byte
File nameファイル名
Exec time実行時間 96 ms
Memory usageメモリ使用量 6272 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt
All 900 / 900 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 91 ms 6272 KB
in10.txt AC 92 ms 6272 KB
in11.txt AC 91 ms 6144 KB
in12.txt AC 10 ms 2944 KB
in13.txt AC 94 ms 6144 KB
in14.txt AC 93 ms 6144 KB
in15.txt AC 96 ms 6144 KB
in16.txt AC 94 ms 6144 KB
in17.txt AC 92 ms 6144 KB
in18.txt AC 92 ms 6144 KB
in19.txt AC 91 ms 6144 KB
in2.txt AC 92 ms 6272 KB
in20.txt AC 91 ms 6144 KB
in21.txt AC 92 ms 6272 KB
in22.txt AC 91 ms 6272 KB
in23.txt AC 94 ms 6144 KB
in24.txt AC 94 ms 6144 KB
in25.txt AC 93 ms 6144 KB
in26.txt AC 92 ms 6144 KB
in27.txt AC 94 ms 6144 KB
in28.txt AC 2 ms 2560 KB
in29.txt AC 2 ms 2560 KB
in3.txt AC 92 ms 6272 KB
in30.txt AC 2 ms 2560 KB
in31.txt AC 95 ms 6144 KB
in32.txt AC 91 ms 6144 KB
in33.txt AC 92 ms 6144 KB
in4.txt AC 91 ms 6272 KB
in5.txt AC 93 ms 6272 KB
in6.txt AC 2 ms 2560 KB
in7.txt AC 92 ms 6272 KB
in8.txt AC 93 ms 6272 KB
in9.txt AC 92 ms 6272 KB
sample1.txt AC 2 ms 2560 KB
sample2.txt AC 2 ms 2560 KB
sample3.txt AC 2 ms 2560 KB