QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#877083#8056. Travel 2FangYifanWA 0ms3584kbC++201.8kb2025-01-31 19:30:262025-01-31 19:30:27

Judging History

This is the latest submission verdict.

  • [2025-01-31 19:30:27]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3584kb
  • [2025-01-31 19:30:26]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
constexpr int mod = 998244353;

constexpr int N = 2510;
vector<int> edge[N];
int n, deg[N], cur[N], cnt[N], vis[N], instk[N], fa[N];
int query(int id) {
    cout << "> " << id << endl;
    int x; cin >> x >> deg[x];
    return x;
}
void dfs(int u, int son) {
    if (!vis[u]) n++;
    cnt[u]++;
    vis[u] = instk[u] = true;
    if (son) {
        for (int i = 0; i < (int)edge[u].size(); i++) {
            int v = edge[u][i];
            if (v == son) {
                query(i + 1);
                // cerr << "1 : " << u << " -> " << v << endl;
                dfs(v, -1);
            }
        }
    }
    for (int &i = cur[u]; i < deg[u]; ) {
        // cerr << u << ' ' << cur[u] << ' ' << deg[u] << "\n";
        int v = query(++i);
        edge[u].push_back(v);
        if (!instk[v]) fa[v] = u;
        // cerr << "2 : " << u << " -> " << v << ' ' << (v == fa[u] ? u : 0) << endl;
        dfs(v, v == fa[u] ? u : 0);
    }
    if (son == -1) {
        for (int i = 0; i < (int)edge[u].size(); i++) {
            int v = edge[u][i];
            if (v == fa[u]) query(i + 1);
        }
    }
    if (--cnt[u] == 0) instk[u] = false;
}
void solve() {
    n = 0;
    int root; cin >> root >> deg[1];
    dfs(1, 0);
    cout << "!";
    for (int i = 1; i <= n; i++) {
        for (auto j : edge[i]) {
            if (i < j) cout << ' ' << i << ' ' << j;
        }
    }
    cout << endl;
    // string Correct; cin >> Correct;
    for (int i = 1; i <= n; i++) {
        deg[i] = cur[i] = cnt[i] = vis[i] = instk[i] = fa[i] = 0;
        edge[i].clear();
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

2
1 1
2 1
1 1
2 1
1 1
Correct
1 3

output:

> 1
> 1
> 1
> 1
! 1 2
!

result:

wrong answer format  Unexpected end of file - int32 expected (test case 2)