QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#439338#8575. Three Person Tree Gamereal_sigma_team#WA 1ms3596kbC++231.7kb2024-06-11 19:48:062024-06-11 19:48:07

Judging History

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

  • [2024-06-11 19:48:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2024-06-11 19:48:06]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--) {
        int n, a, b, c;
        cin >> n >> a >> b >> c;
        --a, --b, --c;
        vector<vector<int>> gr(n);
        for (int i = 1, u, v; i < n; ++i) {
            cin >> u >> v;
            --u, --v;
            gr[u].push_back(v);
            gr[v].push_back(u);
        }
        bool f = false;
        for (int i : gr[a])
            if (i == c) {
                cout << 'A';
                f = true;
            }
        if (f)
            continue;
        vector<int> dist(n), par(n);
        auto dfs = [&](auto self, int v, int p, int d) -> void {
            dist[v] = d;
            par[v] = p;
            for (int u: gr[v])
                if (u != p)
                    self(self, u, v, d + 1);
        };
        dfs(dfs, a, a, 0);
        int lb = b, lc = c;
        while (lb != lc) {
            if (dist[lb] < dist[lc])
                lc = par[lc];
            else
                lb = par[lb];
        }
        int l = lb;
        dfs(dfs, l, l, 0);
        int da = dist[a], db = dist[b], dc = dist[c];
        bool aw = false, bw = false, cw = false;
        if (da < db && da + 1 <= dc)
            aw = true;
        if (db <= da && db < dc)
            bw = true;
        if (dc < da && dc < db)
            cw = true;
        assert(aw + bw + cw <= 1);
        if (aw)
            cout << 'A';
        else if (bw)
            cout << 'B';
        else if (cw)
            cout << 'C';
        else
            cout << "DRAW";
        cout << '\n';
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3596kb

input:

2
3
1 2 3
2 1
3 1
4
1 2 3
1 4
2 4
3 4

output:

ADRAW

result:

wrong answer 1st lines differ - expected: 'A', found: 'ADRAW'