QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659517#8058. Binary vs Ternaryucup-team4992RE 0ms0kbC++141.4kb2024-10-19 20:32:222024-10-19 20:32:26

Judging History

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

  • [2024-10-19 20:32:26]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-19 20:32:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2510, M = 10010;
void solve() {
    vector<vector<int>> G(N), stk(N);
    int id, d;
    cin >> id >> d;
    int n = id;
    G[id].resize(d + 1);
    vector<int> sure(N);
    int sure_cnt = 0;
    auto work = [&]() {
        n = max(n, id);
        G[id].resize(d + 1);
        for (int i = 1; i <= d; i++) {
            int& v = G[id][i];
            if (v) continue;
            cout << "! " << i << '\n';
            cout.flush();
            cin >> v >> d;
            stk[v].push_back(id);
            id = v;
            return;
        }
        if (!sure[id]) {
            sure[id]++;
            sure_cnt++;
        }
        for (int i = 1; i <= d; i++) {
            int& v = G[id][i];
            if (v == stk[id].back()) {
                stk[id].pop_back();
                cout << "! " << i << '\n';
                cout.flush();
                cin >> v >> d;
                id = v;
                return;
            }
        }
    };
    while (sure_cnt < n) {
        work();
    }
    cout << "! ";
    for (int i = 1; i <= n; i++) {
        for (int j = G[i].size() - 1; j >= 1; j--) {
            int& v = G[i][j];
            if (i < v) cout << i << ' ' << v << ' ';
        }
    }
    cout << '\n';
    string cr;
    cin >> cr;
}
int main() {
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

3
1
111
110110
1101010
1111
111111

output:

! 1

result: