AtCoder Grand Contest 014

Submission #1569752

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){
	num+=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]++; if(d[v]!=1 && d[v]!=n-1 && d[v]%2==1) ok=1;
}
int main(){
	cin>>n;
	rep(i,n-1){
		int a,b;cin>>a>>b;edge[a].pb(b);edge[b].pb(a);
	}
	dfs(1,-1,0);
	puts(ok||num*2!=n?"First":"Second");
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt
All 0 / 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 94 ms 6272 KB
in10.txt AC 96 ms 6272 KB
in11.txt WA
in12.txt WA
in13.txt WA
in14.txt WA
in15.txt WA
in16.txt WA
in17.txt WA
in18.txt WA
in19.txt WA
in2.txt AC 96 ms 6272 KB
in20.txt WA
in21.txt AC 96 ms 6272 KB
in22.txt AC 94 ms 6272 KB
in23.txt AC 93 ms 6144 KB
in24.txt AC 94 ms 6144 KB
in25.txt AC 95 ms 6144 KB
in26.txt AC 102 ms 6144 KB
in27.txt AC 94 ms 6144 KB
in28.txt AC 2 ms 2560 KB
in29.txt AC 97 ms 6144 KB
in3.txt AC 95 ms 6272 KB
in30.txt AC 96 ms 6144 KB
in31.txt AC 94 ms 6144 KB
in32.txt AC 115 ms 6144 KB
in33.txt AC 97 ms 6144 KB
in4.txt AC 94 ms 6272 KB
in5.txt AC 94 ms 6272 KB
in6.txt AC 95 ms 6272 KB
in7.txt AC 92 ms 6272 KB
in8.txt AC 96 ms 6272 KB
in9.txt AC 93 ms 6272 KB
sample1.txt AC 2 ms 2560 KB
sample2.txt AC 2 ms 2560 KB
sample3.txt AC 2 ms 2560 KB