QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99798#6345. Random Interactive Convex Hull Botwhatever#WA 2ms3492kbC++171.5kb2023-04-23 19:16:122023-04-23 19:16:14

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-23 19:16:14]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3492kb
  • [2023-04-23 19:16:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
using i64 = long long;
using i128 = __int128_t;
using pii = pair<i64, i64>;
template<typename T> void up(T &x, T y) { if (x < y) x = y; }
template<typename T> void down(T &x, T y) { if (x > y) x = y; }

int query(int i, int j, int k) {
    cout << "? " << i << " " << j << " " << k << endl;
    int res; cin >> res; return res;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n; cin >> n;
    vector<int> nodes{1, 2, 3};
    if (!query(1, 2, 3)) swap(nodes[1], nodes[2]);

    rep(i, 4, n) {
        int m = nodes.size();
        int l = 0, r = m - 1;
        while (l < r) {
            int mid = (l + r + 1) >> 1;
            if (query(nodes[0], nodes[mid], i)) l = mid;
            else r = mid - 1;
        }
        if (l > 0 && l < m - 1 && query(nodes[l], nodes[l + 1], i)) continue;
        if (l + 1 < m) rotate(nodes.begin(), nodes.begin() + l + 1, nodes.end());       
        while ((int) nodes.size() > 2 && query(i, nodes[1], nodes[0])) nodes.erase(nodes.begin());
        while ((int) nodes.size() > 2 && query(i, nodes.back(), nodes[(int) nodes.size() - 2])) nodes.erase(--nodes.end());
        nodes.insert(nodes.begin(), i);
    }

    cout << "! " << nodes.size();
    for (auto x : nodes) cout << " " << x;
    cout << endl;
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3492kb

input:

5
-1
-1
-1
1
-1
-1
1

output:

? 1 2 3
? 1 2 4
? 1 3 4
? 4 2 1
? 4 2 5
? 4 3 5
? 5 2 4
! 3 5 2 3

result:

wrong answer incorrect hull, 7 queries