QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153147#6654. 大纲jiangtaizhe001WA 6ms7656kbC++141.8kb2023-08-29 14:45:062023-08-29 14:45:07

Judging History

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

  • [2023-08-29 14:45:07]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:7656kb
  • [2023-08-29 14:45:06]
  • 提交

answer

#include<cstdio>
#include<iostream>
#define db double
#define pc putchar
#define ll long long
#define Tp template<typename _T>
Tp _T mabs(_T a){ return a<0?-a:a; }
Tp _T mmax(_T a,_T b){ return a<b?b:a; }
Tp _T mmin(_T a,_T b){ return a<b?a:b; }
Tp void mswap(_T &a,_T &b){ _T t=a; a=b; b=t; return; }
using namespace std;
struct IO{
	char buf[1<<21],*p1,*p2;
	char gc(){ return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++; }
	IO & operator >> (char &x){ x=gc(); while(x=='\r'||x=='\n'||x==' ') x=gc(); return *this; }
	Tp IO & operator >> (_T &x){
		x=0; char c=gc(); bool f=0; while(c<'0'||c>'9'){ if(c=='-') f^=1; c=gc(); }
		while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=gc(); f?x=-x:0; return *this;
	}
	int st[39],top;
	IO & operator << (char x) { pc(x); return *this; }
	Tp IO & operator << (_T x){
		if(x<0) x=-x,pc('-'); if(x==0){ pc('0'); return *this; }
		top=0; while(x) st[++top]=x%10,x/=10;
		while(top--) pc(st[top+1]+48); return *this;
	}
}fin;
#define maxn 100039
int n,u,v,head[maxn],to[maxn],nex[maxn],kkk;
#define add(x,y) nex[++kkk]=head[x]; head[x]=kkk; to[kkk]=y
int l[maxn],r[maxn],a[maxn],flag;
void dfs(int x){
		int i,cnt=0; l[x]=r[x]=-1;
	for(i=head[x];i;i=nex[i]){
		dfs(to[i]); l[x]=mmax(l[to[i]],l[x]); r[x]=mmax(r[to[i]],r[x]); cnt++;
	} if(!cnt) l[x]=-1e9,r[x]=2e9; if(cnt>1) l[x]++,r[x]++;
	if(a[x]!=-1){
		if(a[x]<l[x]||a[x]>r[x]) flag=0;
		l[x]=r[x]=a[x];
	} return;
}
void work(){
	fin>>n; int i; kkk=0; for(i=1;i<=n;i++) head[i]=0;
	for(i=1;i<=n;i++) fin>>a[i]; for(i=1;i<n;i++){ fin>>u>>v; add(u,v); }
	flag=1; dfs(1); puts(flag?"Reasonable":"Unreasonable"); return;
}
int main(){
#ifdef LOCAL
	freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
#endif
	int T; fin>>T; while(T--) work(); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 7656kb

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
Reasonable

result:

wrong answer 2nd lines differ - expected: 'Unreasonable', found: 'Reasonable'