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;
int n, m, k, q;
int query(int a, int b, int c) {
cout << "? " << a << ' ' << b << ' ' << c << endl;
int x; cin >> x; return x;
}
void guess(int a, int b, int c) {
cout << "! " << a << ' ' << b << ' ' << c << endl;
}
void sol_1d() {
auto m1 = [&](int a, int b) { return (int)(0.618 * a + 0.382 * b); };
auto m2 = [&](int a, int b) { return (int)(0.382 * a + 0.618 * b); };
int lo = 1, hi = n;
int M1 = -1, M2 = -1;
int M1_v, M2_v;
while (lo < hi) {
if (M1 == -1) { M1 = m1(lo, hi); M1_v = query(M1, 1, 1);}
if (M2 == -1) { M2 = max(m2(lo, hi), M1 + 1); M2_v = query(M2, 1, 1); }
if (M1_v <= M2_v) {
// take second half
lo = M1 + 1;
M1 = M2; M1_v = M2_v;
M2 = -1;
} else {
// take first half
hi = M2 - 1;
M2 = M1; M2_v = M1_v;
M1 = -1;
}
}
guess(lo, 1, 1);
return;
}
void sol_2d() {
cout << "SOL 2D" << endl;
}
void sol_3d() {
cout << "SOL 3D" << endl;
}
int main() {
cin >> n >> m >> k >> q;
if (m == 1 && k == 1) {
sol_1d();
return 0;
}
if (m == 1) {
sol_2d();
return 0;
}
sol_3d();
return 0;
}
# | 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... |