QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234823#6654. 大纲stcmuyi#WA 28ms7988kbC++201.6kb2023-11-01 23:10:282023-11-01 23:10:28

Judging History

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

  • [2023-11-01 23:10:28]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:7988kb
  • [2023-11-01 23:10:28]
  • 提交

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 lmx = 0,cnt = 0,rmx = 0;
            for(int &u : v[x])
            {
                if(u == f) continue;
                if(l[u] > lmx) lmx = l[u],cnt = 1;
                else if(l[u] == lmx) cnt++;
                rmx = max(rmx,r[u]);
            }
            if(r[x] < lmx || l[x] > rmx) ok = 0;
            if(r[x] == lmx && cnt > 1) ok = 0;
            if(cnt > 1) l[x] = lmx+1;
            else l[x] = lmx;
        };
        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: 28ms
memory: 7988kb

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'