Submission #881591

# Submission time Handle Problem Language Result Execution time Memory
881591 2023-12-01T14:57:51 Z epicci23 Mađioničar (COI22_madionicar) C++17
100 / 100
1098 ms 344 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define all(x) ((x).begin(),(x).end())
#define sz(x) ((int)(x).size())

int n;
 
bool ask(int l,int r){
  if(l<1 || r>n) return 0;
  cout << "? " << l << " " << r << endl;
  bool ans; cin >> ans;
  return ans;
}

int search(int l,int r){
  if(ask(l,r)==0) return 0;
  while(ask(l-1,r+1)){l--;r++;}
  return r-l+1;
}

void solve(){
  cin >> n;
  int ans=1;
  
  for(int i=1;i<=n;i++){
    int u = ans/2;
    ans=max(ans,search(i-u,i+u+1));
    u = (ans+1)/2;
    ans=max(ans,search(i-u,i+u));
  }
  
  cout << "! " << ans << endl;
}
 
int32_t main(){
  ios::sync_with_stdio(0);cin.tie(0);
  int t=1;//cin >> t;
  while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 68 ms 344 KB Output is correct
2 Correct 63 ms 344 KB Output is correct
3 Correct 72 ms 344 KB Output is correct
4 Correct 66 ms 344 KB Output is correct
5 Correct 71 ms 344 KB Output is correct
6 Correct 67 ms 344 KB Output is correct
7 Correct 50 ms 344 KB Output is correct
8 Correct 45 ms 344 KB Output is correct
9 Correct 52 ms 344 KB Output is correct
10 Correct 56 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 344 KB Output is correct
2 Correct 63 ms 344 KB Output is correct
3 Correct 72 ms 344 KB Output is correct
4 Correct 66 ms 344 KB Output is correct
5 Correct 71 ms 344 KB Output is correct
6 Correct 67 ms 344 KB Output is correct
7 Correct 50 ms 344 KB Output is correct
8 Correct 45 ms 344 KB Output is correct
9 Correct 52 ms 344 KB Output is correct
10 Correct 56 ms 340 KB Output is correct
11 Correct 636 ms 340 KB Output is correct
12 Correct 649 ms 344 KB Output is correct
13 Correct 587 ms 344 KB Output is correct
14 Correct 604 ms 344 KB Output is correct
15 Correct 585 ms 344 KB Output is correct
16 Correct 474 ms 344 KB Output is correct
17 Correct 494 ms 344 KB Output is correct
18 Correct 677 ms 344 KB Output is correct
19 Correct 515 ms 344 KB Output is correct
20 Correct 621 ms 344 KB Output is correct
21 Correct 615 ms 344 KB Output is correct
22 Correct 721 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1020 ms 344 KB Output is correct
2 Correct 483 ms 344 KB Output is correct
3 Correct 959 ms 344 KB Output is correct
4 Correct 758 ms 344 KB Output is correct
5 Correct 803 ms 344 KB Output is correct
6 Correct 1033 ms 344 KB Output is correct
7 Correct 816 ms 344 KB Output is correct
8 Correct 1004 ms 344 KB Output is correct
9 Correct 1098 ms 344 KB Output is correct
10 Correct 963 ms 344 KB Output is correct
11 Correct 764 ms 344 KB Output is correct
12 Correct 769 ms 344 KB Output is correct
13 Correct 986 ms 344 KB Output is correct
14 Correct 1031 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 344 KB Output is correct
2 Correct 63 ms 344 KB Output is correct
3 Correct 72 ms 344 KB Output is correct
4 Correct 66 ms 344 KB Output is correct
5 Correct 71 ms 344 KB Output is correct
6 Correct 67 ms 344 KB Output is correct
7 Correct 50 ms 344 KB Output is correct
8 Correct 45 ms 344 KB Output is correct
9 Correct 52 ms 344 KB Output is correct
10 Correct 56 ms 340 KB Output is correct
11 Correct 636 ms 340 KB Output is correct
12 Correct 649 ms 344 KB Output is correct
13 Correct 587 ms 344 KB Output is correct
14 Correct 604 ms 344 KB Output is correct
15 Correct 585 ms 344 KB Output is correct
16 Correct 474 ms 344 KB Output is correct
17 Correct 494 ms 344 KB Output is correct
18 Correct 677 ms 344 KB Output is correct
19 Correct 515 ms 344 KB Output is correct
20 Correct 621 ms 344 KB Output is correct
21 Correct 615 ms 344 KB Output is correct
22 Correct 721 ms 344 KB Output is correct
23 Correct 1020 ms 344 KB Output is correct
24 Correct 483 ms 344 KB Output is correct
25 Correct 959 ms 344 KB Output is correct
26 Correct 758 ms 344 KB Output is correct
27 Correct 803 ms 344 KB Output is correct
28 Correct 1033 ms 344 KB Output is correct
29 Correct 816 ms 344 KB Output is correct
30 Correct 1004 ms 344 KB Output is correct
31 Correct 1098 ms 344 KB Output is correct
32 Correct 963 ms 344 KB Output is correct
33 Correct 764 ms 344 KB Output is correct
34 Correct 769 ms 344 KB Output is correct
35 Correct 986 ms 344 KB Output is correct
36 Correct 1031 ms 344 KB Output is correct
37 Correct 1063 ms 344 KB Output is correct
38 Correct 1020 ms 344 KB Output is correct
39 Correct 1051 ms 344 KB Output is correct
40 Correct 1034 ms 344 KB Output is correct
41 Correct 981 ms 344 KB Output is correct
42 Correct 784 ms 344 KB Output is correct
43 Correct 722 ms 344 KB Output is correct
44 Correct 1067 ms 344 KB Output is correct
45 Correct 718 ms 344 KB Output is correct
46 Correct 997 ms 344 KB Output is correct
47 Correct 971 ms 344 KB Output is correct
48 Correct 1067 ms 344 KB Output is correct
49 Correct 773 ms 344 KB Output is correct
50 Correct 743 ms 344 KB Output is correct
51 Correct 968 ms 344 KB Output is correct
52 Correct 959 ms 344 KB Output is correct