QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152428#6654. 大纲rsjWA 59ms8696kbC++14986b2023-08-28 08:23:182023-08-28 08:23:19

Judging History

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

  • [2023-08-28 08:23:19]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:8696kb
  • [2023-08-28 08:23:18]
  • 提交

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(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
*/

详细

Test #1:

score: 0
Wrong Answer
time: 59ms
memory: 8696kb

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:

Unreasonable
Unreasonable

result:

wrong answer 1st lines differ - expected: 'Reasonable', found: 'Unreasonable'