#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
344 KB |
Output is correct |
2 |
Correct |
81 ms |
596 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
82 ms |
504 KB |
Output is correct |
5 |
Correct |
59 ms |
344 KB |
Output is correct |
6 |
Correct |
79 ms |
344 KB |
Output is correct |
7 |
Correct |
69 ms |
344 KB |
Output is correct |
8 |
Correct |
44 ms |
344 KB |
Output is correct |
9 |
Correct |
82 ms |
344 KB |
Output is correct |
10 |
Correct |
63 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
344 KB |
Output is correct |
2 |
Correct |
81 ms |
596 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
82 ms |
504 KB |
Output is correct |
5 |
Correct |
59 ms |
344 KB |
Output is correct |
6 |
Correct |
79 ms |
344 KB |
Output is correct |
7 |
Correct |
69 ms |
344 KB |
Output is correct |
8 |
Correct |
44 ms |
344 KB |
Output is correct |
9 |
Correct |
82 ms |
344 KB |
Output is correct |
10 |
Correct |
63 ms |
344 KB |
Output is correct |
11 |
Correct |
661 ms |
344 KB |
Output is correct |
12 |
Correct |
683 ms |
344 KB |
Output is correct |
13 |
Correct |
712 ms |
344 KB |
Output is correct |
14 |
Correct |
636 ms |
344 KB |
Output is correct |
15 |
Correct |
653 ms |
344 KB |
Output is correct |
16 |
Correct |
667 ms |
344 KB |
Output is correct |
17 |
Correct |
719 ms |
344 KB |
Output is correct |
18 |
Correct |
624 ms |
344 KB |
Output is correct |
19 |
Correct |
624 ms |
344 KB |
Output is correct |
20 |
Correct |
635 ms |
344 KB |
Output is correct |
21 |
Correct |
674 ms |
344 KB |
Output is correct |
22 |
Correct |
689 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1002 ms |
344 KB |
Output is correct |
2 |
Correct |
512 ms |
344 KB |
Output is correct |
3 |
Correct |
1057 ms |
344 KB |
Output is correct |
4 |
Correct |
1008 ms |
344 KB |
Output is correct |
5 |
Correct |
1041 ms |
344 KB |
Output is correct |
6 |
Correct |
1080 ms |
344 KB |
Output is correct |
7 |
Correct |
954 ms |
344 KB |
Output is correct |
8 |
Correct |
963 ms |
344 KB |
Output is correct |
9 |
Correct |
977 ms |
344 KB |
Output is correct |
10 |
Correct |
989 ms |
344 KB |
Output is correct |
11 |
Correct |
941 ms |
344 KB |
Output is correct |
12 |
Correct |
953 ms |
344 KB |
Output is correct |
13 |
Correct |
955 ms |
344 KB |
Output is correct |
14 |
Correct |
1074 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
344 KB |
Output is correct |
2 |
Correct |
81 ms |
596 KB |
Output is correct |
3 |
Correct |
62 ms |
344 KB |
Output is correct |
4 |
Correct |
82 ms |
504 KB |
Output is correct |
5 |
Correct |
59 ms |
344 KB |
Output is correct |
6 |
Correct |
79 ms |
344 KB |
Output is correct |
7 |
Correct |
69 ms |
344 KB |
Output is correct |
8 |
Correct |
44 ms |
344 KB |
Output is correct |
9 |
Correct |
82 ms |
344 KB |
Output is correct |
10 |
Correct |
63 ms |
344 KB |
Output is correct |
11 |
Correct |
661 ms |
344 KB |
Output is correct |
12 |
Correct |
683 ms |
344 KB |
Output is correct |
13 |
Correct |
712 ms |
344 KB |
Output is correct |
14 |
Correct |
636 ms |
344 KB |
Output is correct |
15 |
Correct |
653 ms |
344 KB |
Output is correct |
16 |
Correct |
667 ms |
344 KB |
Output is correct |
17 |
Correct |
719 ms |
344 KB |
Output is correct |
18 |
Correct |
624 ms |
344 KB |
Output is correct |
19 |
Correct |
624 ms |
344 KB |
Output is correct |
20 |
Correct |
635 ms |
344 KB |
Output is correct |
21 |
Correct |
674 ms |
344 KB |
Output is correct |
22 |
Correct |
689 ms |
344 KB |
Output is correct |
23 |
Correct |
1002 ms |
344 KB |
Output is correct |
24 |
Correct |
512 ms |
344 KB |
Output is correct |
25 |
Correct |
1057 ms |
344 KB |
Output is correct |
26 |
Correct |
1008 ms |
344 KB |
Output is correct |
27 |
Correct |
1041 ms |
344 KB |
Output is correct |
28 |
Correct |
1080 ms |
344 KB |
Output is correct |
29 |
Correct |
954 ms |
344 KB |
Output is correct |
30 |
Correct |
963 ms |
344 KB |
Output is correct |
31 |
Correct |
977 ms |
344 KB |
Output is correct |
32 |
Correct |
989 ms |
344 KB |
Output is correct |
33 |
Correct |
941 ms |
344 KB |
Output is correct |
34 |
Correct |
953 ms |
344 KB |
Output is correct |
35 |
Correct |
955 ms |
344 KB |
Output is correct |
36 |
Correct |
1074 ms |
344 KB |
Output is correct |
37 |
Correct |
1050 ms |
344 KB |
Output is correct |
38 |
Correct |
957 ms |
344 KB |
Output is correct |
39 |
Correct |
1036 ms |
344 KB |
Output is correct |
40 |
Correct |
1061 ms |
344 KB |
Output is correct |
41 |
Correct |
1090 ms |
344 KB |
Output is correct |
42 |
Correct |
968 ms |
344 KB |
Output is correct |
43 |
Correct |
1092 ms |
344 KB |
Output is correct |
44 |
Correct |
971 ms |
344 KB |
Output is correct |
45 |
Correct |
955 ms |
344 KB |
Output is correct |
46 |
Correct |
1012 ms |
344 KB |
Output is correct |
47 |
Correct |
1037 ms |
344 KB |
Output is correct |
48 |
Correct |
998 ms |
344 KB |
Output is correct |
49 |
Correct |
1000 ms |
344 KB |
Output is correct |
50 |
Correct |
796 ms |
344 KB |
Output is correct |
51 |
Correct |
1036 ms |
596 KB |
Output is correct |
52 |
Correct |
1008 ms |
344 KB |
Output is correct |