QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152429#6654. 大纲rsjWA 232ms15408kbC++141.0kb2023-08-28 08:24:222023-08-28 08:24:22

Judging History

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

  • [2023-08-28 08:24:22]
  • 评测
  • 测评结果:WA
  • 用时:232ms
  • 内存:15408kb
  • [2023-08-28 08:24:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
struct edge {
	int to;
	edge *nex;
}*head[N];
int l[N],r[N],ok;
void add(int u,int v) {
	edge *cur=new edge;
	cur->to=v;
	cur->nex=head[u];
	head[u]=cur;
}
void dfs(int u) {
	int L=0,R=0;
	int a1=0,a2=0;
	for(edge *cur=head[u];cur;cur=cur->nex) {
		dfs(cur->to);
		L=max(L,l[cur->to]);
		R=max(R,r[cur->to]);
	}
	for(edge *cur=head[u];cur;cur=cur->nex) {
		if(L==l[cur->to]) a1++;
		if(R==r[cur->to]) a2++;
	}
	if(L==0&&R==0) {
		L=0,R=2e9;
		return ;
	}
	if(a1>1) L++;
	if(a2>1) R++;
	l[u]=max(l[u],L);
	r[u]=min(r[u],R);
	if(l[u]>r[u]) ok=0;
}
void get() {
	ok=1;
	int n,i,u,v;
	cin>>n;
	for(i=1;i<=n;i++) {
		cin>>l[i],head[i]=0;
		if(l[i]==-1) l[i]=0,r[i]=2e9;
		else r[i]=l[i];
	}
	for(i=1;i<n;i++) cin>>u>>v,add(u,v);
	dfs(1);
	if(ok) cout<<"Reasonable\n"; else cout<<"Unreasonable\n";
}
signed main() {
	int T; cin>>T;
	while(T--) get();
	return 0;
}
/*
1
3
0 -1 0
1 2
2 3

1
3
0 -1 0
1 2
1 3
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 74ms
memory: 8748kb

input:

2
65535
-1 1000000000 -1 1000000000 1000000000 1000000000 -1 -1 -1 -1 -1 -1 1000000000 1000000000 1000000000 1000000000 -1 1000000000 1000000000 -1 1000000000 -1 1000000000 1000000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 1000000000 1000000000 -1 1000000000 -1 -1 -1 1000000000 1000000000 1000000000 1000000000 ...

output:

Reasonable
Unreasonable

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 63ms
memory: 8764kb

input:

2
65535
1000000000 -1 -1 -1 1000000000 -1 -1 -1 -1 -1 1000000000 1000000000 -1 1000000000 -1 -1 -1 -1 1000000000 -1 1000000000 1000000000 -1 1000000000 1000000000 -1 1000000000 -1 1000000000 -1 1000000000 1000000000 -1 -1 1000000000 -1 -1 1000000000 1000000000 1000000000 -1 -1 -1 -1 1000000000 10000...

output:

Unreasonable
Reasonable

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 79ms
memory: 15408kb

input:

2
99999
49999 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

Reasonable
Reasonable

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 189ms
memory: 6772kb

input:

100000
2
503237730 503237730
1 2
2
940454426 940454426
1 2
2
248079005 -1
1 2
2
74614856 74614857
1 2
2
64379558 64379558
1 2
2
306909809 -1
1 2
2
-1 966615641
1 2
2
698391106 698391107
1 2
2
223750421 -1
1 2
2
705201637 705201637
1 2
2
256204065 -1
1 2
2
723177111 168932444
1 2
2
228089673 22808967...

output:

Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Reasonable
Reasonable
Un...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 232ms
memory: 7792kb

input:

66666
3
530204916 -1 -1
2 3
1 2
3
476528072 476528072 476528072
1 2
2 3
3
-1 841888306 841888306
1 3
1 2
3
319191766 319191766 -1
3 2
1 3
3
177048577 531221023 -1
1 2
1 3
3
598759147 991100533 416954424
1 3
3 2
3
210423414 263192668 -1
1 2
1 3
3
902429034 -1 961317874
1 3
1 2
3
662280681 -1 33815376...

output:

Reasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Unreasonable
Reasonable
Unreasonable
Unreasonable
Reasonable...

result:

ok 66666 lines

Test #6:

score: -100
Wrong Answer
time: 159ms
memory: 8328kb

input:

50000
3
-1 6 6
1 3
1 2
5
0 -1 -1 0 -1
4 5
4 2
2 3
1 4
3
859025665 859025665 859025665
1 2
2 3
4
1 1 1 1
3 2
2 4
1 3
3
2 -1 -1
3 2
1 3
4
2 1 1 2
4 2
1 4
4 3
2
2 2
1 2
3
-1 1 2
1 3
3 2
3
1 1 1
1 3
3 2
2
-1 8
1 2
4
4 4 296285101 1
2 3
1 2
1 4
4
-1 -1 -1 0
2 4
1 2
2 3
5
-1 0 0 0 0
1 4
1 2
1 5
1 3
4
-1 6...

output:

Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Reasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Unreasonable
Reasonable
Reasonable
Unreasonable
Unreasonable
Reasonable
Unreasonabl...

result:

wrong answer 166th lines differ - expected: 'Unreasonable', found: 'Reasonable'