QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#879968#8056. Travel 2FangYifanRE 0ms0kbC++201.2kb2025-02-02 19:12:222025-02-02 19:12:22

Judging History

This is the latest submission verdict.

  • [2025-02-02 19:12:22]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2025-02-02 19:12:22]
  • Submitted

answer

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

constexpr int N = 2510;
int n, deg[N];
int move(int id) {
    cout << "> " << id << endl;
    int x; cin >> x >> deg[x];
    n = max(n, x);
    return x;
}
vector<int> edge[N];
int vis[N], cur[N], adj[N][N];
void dfs(int u, int fa) {
    for (int &i = cur[u]; i < deg[u];) {
        int v = move(++i);
        edge[u].push_back(v);
        adj[u][v] = i;
        if (v == fa) move(adj[fa][u]);
        else dfs(v, u);
    }
    if (fa) move(adj[fa][u]);
}
void solve() {
    int x;
    cin >> x >> 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] = vis[i] = cur[i] = 0;
        for (auto j : edge[i]) adj[i][j] = 0;
        edge[i].clear();
    }
    n = 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:

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

result: