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;
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define per(i, a, b) for (int i = b - 1; i >= a; --i)
#define trax(a, x) for (auto& a : x)
#define sz(a) a.size()
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
vector<vvi> grid;
int x, y, z, q;
bool check(int a, int b, int c) {
int val = grid[a][b][c];
if (a && val < grid[a - 1][b][c]) return 0;
if (a + 1 < x && val < grid[a + 1][b][c]) return 0;
if (b && val < grid[a][b - 1][c]) return 0;
if (b + 1 < y && val < grid[a][b + 1][c]) return 0;
if (c && val < grid[a][b][c - 1]) return 0;
if (c + 1 < z && val < grid[a][b][c + 1]) return 0;
return 1;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> x >> y >> z >> q;
grid.resize(x, vvi(y, vi(z)));
if (y == 1 && z == 1) {
vi arr(x + 2, 0);
arr[0] = arr[x + 1] = 1;
int lo = 1, hi = x;
while (true) {
if (lo >= hi) {
cout << "! " << lo << " 1 1" << endl;
break;
}
int mid = (lo + hi) >> 1, n1, n2, n3;
if (arr[mid - 1])
n1 = arr[mid - 1];
else {
cout << "? " << mid - 1 << " 1 1" << endl;
cin >> n1;
arr[mid - 1] = n1;
}
if (arr[mid])
n2 = arr[mid];
else {
cout << "? " << mid << " 1 1" << endl;
cin >> n2;
arr[mid] = n2;
}
if (n2 < n1) {
hi = mid - 1;
continue;
}
if (arr[mid + 1])
n3 = arr[mid + 1];
else {
cout << "? " << mid + 1 << " 1 1" << endl;
cin >> n3;
arr[mid + 1] = n3;
}
if (n1 <= n2 && n3 <= n2) {
cout << "! " << mid << " 1 1" << endl;
break;
} else if (n2 < n3)
lo = mid + 1;
}
}
}
# | 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... |