QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99798 | #6345. Random Interactive Convex Hull Bot | whatever# | WA | 2ms | 3492kb | C++17 | 1.5kb | 2023-04-23 19:16:12 | 2023-04-23 19:16:14 |
Judging History
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