QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#877465#8056. Travel 2FangYifanRE 1ms3584kbC++201.3kb2025-01-31 22:32:062025-01-31 22:32:06

Judging History

This is the latest submission verdict.

  • [2025-01-31 22:32:06]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 3584kb
  • [2025-01-31 22:32:06]
  • 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];
vector<int> edge[N];
int move(int id) {
    cout << "> " << id << endl;
    int x; cin >> x >> deg[x];
    return x;
}
int cur[N], vis[N], fa[N], adj[N][N];
void dfs(int u) {
    if (!vis[u]) ++n;
    vis[u] = true;
    for (int &i = cur[u]; i < deg[u];) {
        int v = move(++i);
        edge[u].push_back(v);
        adj[u][v] = i;
        if (v > 1 && fa[v] == 0) fa[v] = u;
        if (v == fa[u]) {
            move(adj[v][u]);
        } else {
            dfs(v);
        }
    }
    if (adj[u][fa[u]]) move(adj[u][fa[u]]);
}
void solve() {
    int root; cin >> root >> deg[1];
    dfs(1);
    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] = vis[i] = fa[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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3584kb

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
1 3
4 2
2 2
4 2
2 2
4 2
1 3
Correct

output:

> 1
> 1
> 1
> 1
! 1 2
> 1
> 1
> 1
> 2
> 1
> 2
> 1
> 2
> 1
> 3
> 2
> 2
> 2
> 2
> 1
! 1 2 1 3 1 4 2 4

result:

ok correct! (2 test cases)

Test #2:

score: -100
Runtime Error

input:

1000
1 9
2 7
1 9
2 7
3 9
1 9
3 9
4 9
1 9
4 9
3 9
4 9
7 7
1 9
5 8
1 9
5 8
8 8
1 9
6 9
1 9
6 9
2 7
10 6
1 9
7 7
4 9
7 7
8 8
5 8
8 8
10 6
2 7
10 6
8 8
9 8
1 9
8 8
7 7
5 8
9 8
3 9
9 8
5 8
2 7
6 9
10 6
4 9
10 6
6 9
5 8
3 9
2 7
3 9
5 8
6 9
8 8
3 9
10 6
3 9
8 8
6 9
3 9
7 7
3 9
6 9
9 8
2 7
5 8
7 7
9 8
8 8
9...

output:

> 1
> 1
> 1
> 2
> 1
> 2
> 2
> 1
> 3
> 2
> 2
> 3
> 1
> 4
> 1
> 4
> 2
> 1
> 5
> 1
> 5
> 2
> 3
> 1
> 6
> 2
> 3
> 3
> 2
> 2
> 3
> 2
> 3
> 3
> 4
> 1
> 7
> 5
> 4
> 3
> 2
> 3
> 3
> 4
> 4
> 3
> 4
> 4
> 5
> 4
> 5
> 4
> 2
> 5
> 6
> 5
> 6
> 6
> 6
> 7
> 7
> 6
> 8
> 5
> 9
> 7
> 4
> 5
> 7
> 6
> 5
> 4
> 6
> 7
> 8
...

result: