This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<int> p{0, 1, 2};
int get(vector<int> pos) {
cout << "? " << pos[p[0]] << ' ' << pos[p[1]] << ' ' << pos[p[2]] << endl;
int h; cin >> h;
return h;
}
void rek(vector<pair<int, int>> a) {
sort(p.begin(), p.end(), [&a](int i, int j) {
return a[i].second - a[i].first > a[j].second - a[j].first;
});
int max_val = -1;
vector<int> max_pos;
if (a[0].second - a[0].first == 2) {
for (int i = a[0].first; i <= a[0].second; i++) {
for (int j = a[1].first; j <= a[1].second; j++) {
for (int k = a[2].first; k <= a[2].second; k++) {
int cur_val = get({i, j, k});
if (cur_val > max_val) {
max_val = cur_val;
max_pos = {i, j, k};
}
}
}
}
cout << "! " << max_pos[p[0]] << ' ' << max_pos[p[1]] << ' ' << max_pos[p[2]] << '\n';
return;
}
int m = (a[0].first + a[0].second) >> 1;
for (int i = a[1].first; i <= a[1].second; i++) {
for (int j = a[2].first; j <= a[2].second; j++) {
int cur_val = get({m, i, j});
if (cur_val > max_val) {
max_val = cur_val;
max_pos = {m, i, j};
}
}
}
vector<int> L_pos = max_pos;
vector<int> R_pos = max_pos;
L_pos[0]--;
R_pos[0]++;
if (get(L_pos) < get(R_pos)) {
a[0].first = m;
}
else {
a[0].second = m;
}
rek(a);
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int n, m, k, q; cin >> n >> m >> k >> q;
rek({{1, n}, {1, m}, {1, k}});
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |