제출 #399883

#제출 시각아이디문제언어결과실행 시간메모리
399883SortingWorm Worries (BOI18_worm)C++17
10 / 100
2 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3; int n, m, k, q; int arr[N]; int query(int x){ if(arr[x]) return arr[x]; cout << "? " << x << " " << 1 << " " << 1 << "\n"; cout.flush(); cin >> arr[x]; return arr[x]; } void answer(int x){ cout << "! " << x << " " << 1 << " " << 1 << "\n"; cout.flush(); exit(0); } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k >> q; int l = 1, r = n; while(l + 2 < r){ int mid1 = (int)round(0.618 * l + 0.382 * r); int mid2 = (int)round(0.382 * l + 0.618 * r); if(mid1 == mid2){ if(mid1 != l) --mid1; else ++mid2; } //cout << mid1 << " - " << mid2 << endl; int a = query(mid1), b = query(mid2); if(a >= b) r = mid2 - 1; else l = mid1 + 1; } if(l + 2 == r){ int a = query(l), b = query(r); if(a >= b) answer(l); else ++l; } if(l + 1 == r){ int a = query(l), b = query(r); if(a < b) l = r; } answer(l); }
#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...