QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#152557 | #6654. 大纲 | Scene | WA | 28ms | 12192kb | C++14 | 2.0kb | 2023-08-28 11:30:56 | 2023-08-28 11:30:56 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define Ts template<typename Ty,typename... Ar>
#define Tp template<typename Ty>
#define ll long long
#define RS register
#define gc getchar
#define pc putchar
#define I inline
using namespace std;
Tp I Ty wmax(Ty a,Ty b){return a>=b? a:b;}
Tp I Ty wmin(Ty a,Ty b){return a<=b? a:b;}
namespace WrongIO
{
Tp I void read(Ty &x){x=0;Ty opt=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();if(c=='-')opt=-1,c=gc();while(isdigit(c))x=(x<<3)+(x<<1),x+=c-'0',c=gc();x*=opt;return;}
Tp I void write(Ty x){short OI_USE[50],OI_top=0;if(x<=0) if(x==0)pc('0');else pc('-'),x*=-1;while(x)OI_USE[++OI_top]=x%10,x/=10;while(OI_top--)pc(OI_USE[OI_top+1]+'0');return;}
I void writec(char c[]){int len=strlen(c);for(int i=0;i<len;i++)pc(c[i]);}
I void writes(string s){int len=s.length();for(int i=0;i<len;i++)pc(s[i]);}
I void readc(char &c,int l,int r){c=gc(); while(c!=EOF&&(c<l||c>r)) c=gc();}
I void readc(char &c,char val){c=gc();while(c!=EOF&&c!=val) c=gc();}
I void readc(char val){char c;c=gc();while(c!=EOF&&c!=val) c=gc();}
I void readls(string &s){char c=gc();while(c!='\n') s.push_back(c),c=gc();}
Ts I void read(Ty &x,Ar &...y) {read(x),read(y...);}
} using namespace WrongIO;
ll T; bool ans;
ll L[100050],R[100050],n;
vector<ll> vt[100050];
void dfs(ll u)
{
ll minx=0,cf1=0;
ll maxn=0,cf2=0;
for(ll v:vt[u])
dfs(v);
if(vt[u].size()==0) minx=0,maxn=1e16;
for(ll v:vt[u])
{
if(L[v]>minx) minx=L[v],cf1=0;
else if(L[v]==minx) cf1=1;
if(R[v]>maxn) maxn=R[v],cf2=0;
else if(R[v]==maxn) cf2=1;
}
minx+=cf1==1? 1:0; maxn+=cf2==1? 1:0;
if(L[u]==-1) L[u]=minx,R[u]=maxn;
else if(!(minx<=L[u]&&R[u]<=maxn)) ans=0;
return;
}
int main()
{
read(T);
while(T--)
{
read(n); for(int i=1;i<=n;i++) read(L[i]),R[i]=L[i],vt[i].clear();
ll a,b; for(int i=1;i<n;i++) read(a,b),vt[a].push_back(b);
ans=1; dfs(1); if(ans) writes("Reasonable\n"); else writes("Unreasonable\n");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 24ms
memory: 9044kb
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: 14ms
memory: 8692kb
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: 28ms
memory: 12192kb
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: 3ms
memory: 5928kb
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: 7ms
memory: 6200kb
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: 17ms
memory: 6288kb
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 Unreasonable Unreasonable Unreasonable Reasonable Unreasona...
result:
wrong answer 22nd lines differ - expected: 'Reasonable', found: 'Unreasonable'