제출 #702769

#제출 시각아이디문제언어결과실행 시간메모리
702769Shreyan_PaliwalWorm Worries (BOI18_worm)C++17
10 / 100
1 ms292 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...