QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572127#8948. 报复社会dieselhuang0 10ms9748kbC++14934b2024-09-18 12:16:312024-09-18 12:16:32

Judging History

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

  • [2024-09-18 12:16:32]
  • 评测
  • 测评结果:0
  • 用时:10ms
  • 内存:9748kb
  • [2024-09-18 12:16:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define GC()	getchar()
#define PC(x)	putchar(x)
int n, a[500010], fa[500010], hd[500010], nxt[500010];
struct A{
	int fl, x;
};
int read(){
	int res = 0;
	char c;
	do c = GC();
	while(c < '0' || c > '9');
	while(c >= '0' && c <= '9'){
		res = (res << 3) + (res << 1) + c - '0';
		c = GC();
	}
	return res;
}
int dfs(int u){
	int v, x = 0;
	if(hd[u] == 0) return 1 - (a[u] << 1);
	for(v = hd[u]; v > 0; v = nxt[v]){
		x += dfs(v);
	}
	if(x < 0 || n & 1) x--;
	else x++;
	return x;
}
void solve(){
	int i;
	A ans;
	n = read();
	for(i = 1; i <= n; i++) hd[i] = 0;
	for(i = 2; i <= n; i++){
		fa[i] = read();
		nxt[i] = hd[fa[i]]; hd[fa[i]] = i;
	}
	for(i = 1; i <= n; i++) a[i] = read(); 
	if(dfs(1) > 0){ PC('y'); PC('e'); PC('s'); }
	else{ PC('n'); PC('o'); }
	PC('\n');
}
int main()
{
	int t;
	t = read();
	while(t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 9684kb

input:

1
19
1 2 3 3 2 6 7 7 6 6 6 2 2 2 1 1 1 1
0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0

output:

no

result:

wrong answer 1st words differ - expected: 'Bob', found: 'no'

Subtask #2:

score: 0
Wrong Answer

Test #50:

score: 0
Wrong Answer
time: 8ms
memory: 9748kb

input:

10000
49
1 2 2 1 5 5 5 5 5 5 1 12 12 12 12 12 12 1 19 19 19 19 19 19 19 1 27 27 1 1 31 1 33 33 33 33 33 33 33 1 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1
50
1 2 2 2 2 2 1 8 8 8 1 12 1 1 15 15 15 15 1 1 21 21 21 21 1 26 1 1 29 29...

output:

no
yes
yes
no
no
yes
no
no
yes
no
no
yes
no
no
yes
yes
no
no
yes
no
no
yes
no
yes
no
no
no
yes
no
no
yes
no
no
no
yes
yes
no
no
yes
no
no
no
no
yes
no
no
yes
no
no
no
yes
no
no
no
no
no
yes
no
yes
no
yes
no
no
no
no
no
no
yes
no
no
no
yes
no
no
no
no
no
yes
yes
no
no
no
no
no
yes
no
no
yes
no
no
yes...

result:

wrong answer 1st words differ - expected: 'Bob', found: 'no'

Subtask #3:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 10ms
memory: 9744kb

input:

10000
50
1 2 1 4 5 6 5 4 9 4 11 4 1 14 15 16 16 16 15 14 21 21 21 14 14 14 14 14 1 30 30 30 30 30 1 36 37 37 37 36 41 41 41 36 1 1 1 1 1
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1
50
1 2 3 4 5 4 7 8 7 4 11 12 11 14 11 16 11 18 11 4 21 4 4 4 3 ...

output:

yes
yes
yes
yes
no
no
yes
no
yes
yes
no
no
no
yes
no
yes
yes
no
no
no
no
no
yes
no
no
no
yes
yes
no
no
yes
yes
no
no
yes
yes
yes
yes
no
yes
no
yes
yes
yes
no
no
yes
no
no
no
no
yes
no
yes
no
yes
no
no
yes
no
yes
yes
yes
no
no
no
no
no
no
yes
no
no
yes
no
no
yes
yes
no
no
no
yes
no
no
yes
yes
no
no
n...

result:

wrong answer 1st words differ - expected: 'Alice', found: 'yes'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%