Submission #1274095

#TimeUsernameProblemLanguageResultExecution timeMemory
1274095thesenMađioničar (COI22_madionicar)C++20
0 / 100
3298 ms1960 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define vll vector<ll> #define vbool vector<bool> #define pairll pair<ll,ll> #define fi first #define sc second #define rever greater<ll>() using namespace std; void solve(){ ll n; cin >> n; vll a(n*2, 1); ll x; for(ll i = 2; i < n*2;){ if((i+(a[i]/2+1)) > n*2)break; if(i-(a[i]/2+1) >= 1){ if((i-(a[i]/2+1))%2 == 0){ a[i]+=2; continue; } //cout << i << ' ' << a[i] << endl; cout << "? " << (i-(a[i]/2+1))/2+1 << ' ' << (i+(a[i]/2+1))/2+1 << endl; fflush(stdout); cin >> x; if(x){ a[i]+=2; continue; } } ll k = (a[i]/2)+1; for(ll j = 1; j <= a[i]/2; j++){ if(i+(a[i]/2) == i+j + a[i-j]/2){ k = min(k, j); } if(i+(a[i]/2) < i+j + a[i-j]/2){ a[i+j] = (i+(a[i]/2))-(i+j); a[i+j]*=2; a[i+j]++; }else a[i+j] = a[i-j]; }i+=k; } ll res = 0; for(ll i = 1; i < 2*n; i++){ res = max(res, a[i]/2); }cout << "! " << res << endl; fflush(stdout); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll t=1; //cin >> t; for(int i = 1; i <= t; i++){ 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...