QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261563#4589. White-Black TreeNYCU_gAwr_gurA#RE 0ms0kbC++17813b2023-11-22 23:42:012023-11-22 23:42:02

Judging History

你现在查看的是最新测评结果

  • [2023-11-22 23:42:02]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-22 23:42:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define endl '\n'
#define cerr if(1);else cerr
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second

using ll = long long;
using ld = long double;
using pii = pair<int,int>;

vector<int> G[100010];
int arr[100010];

int dfs(int a, bool tag)
{
	int res=0;
	arr[a]^=tag;
	res+=arr[a];
	tag^=arr[a];
	for(int b:G[a])
		res+=dfs(b,tag);
}

signed main() {
	fast;
	
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		int a;
		cin>>a;
		G[a].emplace_back(i);
	}
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	if(!dfs(1,0))
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	
	cerr _ "meow" _ endl;
	
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

7
1 1 1 3 3 3
0 1 1 0 0 0 1

output:


result: