제출 #843129

#제출 시각아이디문제언어결과실행 시간메모리
843129groguMađioničar (COI22_madionicar)C++14
100 / 100
1092 ms596 KiB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;

ll n;
bool dbg = 0;
string s;
bool check(ll l,ll r){
    l--;
    r--;
    while(l<=r){
        if(s[l]!=s[r]) return 0;
        l++;
        r--;
    }
    return 1;
}
bool ask(ll l,ll r){
    if(l<1) return 0;
    cout<<"? "<<l<< " "<<r<<endl;
    bool ans;
    if(dbg) return check(l,r);
    cin >> ans;
    return ans;
}
int main(){
    cin >> n;
    if(dbg) cin >> s;
    ll ans = 1;
    for(ll i = 2;i<=n;i++){
        if(ask(i-ans-1,i)) ans+=2;
        else if(ask(i-ans,i)) ans++;
    }
    cout<<"! "<<ans<<endl;
	return (0-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...