QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234816 | #6654. 大纲 | stcmuyi# | WA | 30ms | 7572kb | C++20 | 1.5kb | 2023-11-01 23:06:41 | 2023-11-01 23:06:41 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define endl '\n'
#define lb(x) ((x) & (-x))
using namespace std;
const i64 mod = 1e9+7;
const int maxn = 1e4+10;
signed main()
{
IOS;
int t; cin >> t;
while(t--)
{
int n; cin >> n;
vector<int> l(n+1),r(n+1);
for(int i = 1; i <= n; ++i)
{
cin >> l[i];
r[i] = l[i];
if(l[i] == -1) l[i] = 0,r[i] = mod;
}
vector<vector<int>> v(n+1);
for(int i = 1; i < n; ++i)
{
int x,y; cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
bool ok = 1;
auto dfs = [&](auto self,int x,int f) -> void
{
bool vis = 0;
for(int &u : v[x])
{
if(u == f) continue;
vis = 1;
self(self,u,x);
}
if(!vis) return;
int mx = 0,cnt = 0;
for(int &u : v[x])
{
if(u == f) continue;
if(l[u] > mx) mx = l[u],cnt = 1;
else if(l[u] == mx) cnt++;
}
if(r[x] < mx) ok = 0;
if(r[x] == mx && cnt > 1) ok = 0;
if(cnt > 1) l[x] = mx+1;
else l[x] = mx;
};
dfs(dfs,1,0);
cout << (ok ? "Reasonable" : "Unreasonable") << endl;
}
return 0;
}
/*
2
3
0 -1 0
1 2
2 3
3
0 -1 0
1 2
1 3
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 30ms
memory: 7572kb
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'