QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234816#6654. 大纲stcmuyi#WA 30ms7572kbC++201.5kb2023-11-01 23:06:412023-11-01 23:06:41

Judging History

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

  • [2023-11-01 23:06:41]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:7572kb
  • [2023-11-01 23:06:41]
  • 提交

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'