Submission #541431

#TimeUsernameProblemLanguageResultExecution timeMemory
541431LoboWorm Worries (BOI18_worm)C++17
10 / 100
2 ms336 KiB
#include<bits/stdc++.h> using namespace std; const long long inf = (long long) 1e18 + 10; const int inf1 = (int) 1e9 + 10; #define int long long #define dbl long double // #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() const int maxn = 1e6 + 10; int n,aux,a[maxn]; int qrr(int x) { if(x == 0 || x == n+1 || a[x] != 0) return a[x]; cout << "? " << x << " 1 1" << endl; int o; cin >> o; if(o == -1) exit(0); return o; } void solve() { cin >> n >> aux >> aux >> aux; int l = 1; int r = n; int m1 = (l+r)/2; a[m1] = qrr(m1); int ans; while(l < r) { int mid = (l+r)/2; int m2; if(m1 > mid) { //m2 fica no 1/3 m2 = l+(r-l+1)/3; } else { //m2 fica no 2/3 m2 = r-(r-l+1)/3; } if(m1 > m2) swap(m1,m2); a[m1] = qrr(m1); a[m2] = qrr(m2); if(a[m1] >= a[m2]) { //interval (l,m2-1) ans = l; r = m2-1; } else { //interval (m1+1,r) ans = r; l = m1+1; m1 = m2; } } cout << "! " << ans << " 1 1" << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("in.in", "r", stdin); // freopen("out.out", "w", stdout); int tt = 1; // cin >> tt; while(tt--) solve(); }
#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...