Submission #1114538

# Submission time Handle Problem Language Result Execution time Memory
1114538 2024-11-19T07:21:19 Z SalihSahin Mađioničar (COI22_madionicar) C++14
100 / 100
3812 ms 336 KB
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
 
const int inf = 1e15 + 10;
const int N = 3e5 + 5;

bool query(int l, int r){
   cout<<"? "<<l<<" "<<r<<"\n";
   cout.flush();

   bool pal;
   cin>>pal;
   return pal;
}

int32_t main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
   int n;
   cin>>n;

   int oddmx = 1, evenmx = 0;
   for(int i = 1; i <= n; i++){
      int st = oddmx + 2;

      for(int len = st; len <= n; len += 2){
         int l = i - (len - 1)/2, r = i + (len - 1)/2;
         if(l < 1 || r > n) break;
         bool pal = query(l, r);
         if(!pal) break;
         oddmx = len;
      }
   }

   for(int i = 1; i <= n; i++){
      int st = max(oddmx + 1, evenmx + 2);

      for(int len = st; len <= n; len += 2){
         int l = i - len/2 + 1, r = i + len/2;
         if(l < 1 || r > n) break;
         bool pal = query(l, r);
         if(!pal) break;
         evenmx = len;
      }
   }

   int ans = max(oddmx, evenmx);
   cout<<"! "<<ans<<endl;
   cout.flush();
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 263 ms 336 KB Output is correct
2 Correct 276 ms 336 KB Output is correct
3 Correct 268 ms 336 KB Output is correct
4 Correct 261 ms 336 KB Output is correct
5 Correct 277 ms 336 KB Output is correct
6 Correct 255 ms 336 KB Output is correct
7 Correct 114 ms 336 KB Output is correct
8 Correct 133 ms 336 KB Output is correct
9 Correct 245 ms 336 KB Output is correct
10 Correct 258 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 336 KB Output is correct
2 Correct 276 ms 336 KB Output is correct
3 Correct 268 ms 336 KB Output is correct
4 Correct 261 ms 336 KB Output is correct
5 Correct 277 ms 336 KB Output is correct
6 Correct 255 ms 336 KB Output is correct
7 Correct 114 ms 336 KB Output is correct
8 Correct 133 ms 336 KB Output is correct
9 Correct 245 ms 336 KB Output is correct
10 Correct 258 ms 336 KB Output is correct
11 Correct 2410 ms 336 KB Output is correct
12 Correct 2372 ms 336 KB Output is correct
13 Correct 2368 ms 336 KB Output is correct
14 Correct 2268 ms 336 KB Output is correct
15 Correct 2308 ms 336 KB Output is correct
16 Correct 1202 ms 336 KB Output is correct
17 Correct 1231 ms 336 KB Output is correct
18 Correct 2446 ms 336 KB Output is correct
19 Correct 1185 ms 336 KB Output is correct
20 Correct 2407 ms 336 KB Output is correct
21 Correct 2334 ms 336 KB Output is correct
22 Correct 2300 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3748 ms 336 KB Output is correct
2 Correct 963 ms 336 KB Output is correct
3 Correct 3660 ms 336 KB Output is correct
4 Correct 2356 ms 336 KB Output is correct
5 Correct 1837 ms 336 KB Output is correct
6 Correct 3793 ms 336 KB Output is correct
7 Correct 1856 ms 336 KB Output is correct
8 Correct 3760 ms 336 KB Output is correct
9 Correct 3727 ms 336 KB Output is correct
10 Correct 3789 ms 336 KB Output is correct
11 Correct 1891 ms 336 KB Output is correct
12 Correct 1851 ms 336 KB Output is correct
13 Correct 3761 ms 336 KB Output is correct
14 Correct 3652 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 336 KB Output is correct
2 Correct 276 ms 336 KB Output is correct
3 Correct 268 ms 336 KB Output is correct
4 Correct 261 ms 336 KB Output is correct
5 Correct 277 ms 336 KB Output is correct
6 Correct 255 ms 336 KB Output is correct
7 Correct 114 ms 336 KB Output is correct
8 Correct 133 ms 336 KB Output is correct
9 Correct 245 ms 336 KB Output is correct
10 Correct 258 ms 336 KB Output is correct
11 Correct 2410 ms 336 KB Output is correct
12 Correct 2372 ms 336 KB Output is correct
13 Correct 2368 ms 336 KB Output is correct
14 Correct 2268 ms 336 KB Output is correct
15 Correct 2308 ms 336 KB Output is correct
16 Correct 1202 ms 336 KB Output is correct
17 Correct 1231 ms 336 KB Output is correct
18 Correct 2446 ms 336 KB Output is correct
19 Correct 1185 ms 336 KB Output is correct
20 Correct 2407 ms 336 KB Output is correct
21 Correct 2334 ms 336 KB Output is correct
22 Correct 2300 ms 336 KB Output is correct
23 Correct 3748 ms 336 KB Output is correct
24 Correct 963 ms 336 KB Output is correct
25 Correct 3660 ms 336 KB Output is correct
26 Correct 2356 ms 336 KB Output is correct
27 Correct 1837 ms 336 KB Output is correct
28 Correct 3793 ms 336 KB Output is correct
29 Correct 1856 ms 336 KB Output is correct
30 Correct 3760 ms 336 KB Output is correct
31 Correct 3727 ms 336 KB Output is correct
32 Correct 3789 ms 336 KB Output is correct
33 Correct 1891 ms 336 KB Output is correct
34 Correct 1851 ms 336 KB Output is correct
35 Correct 3761 ms 336 KB Output is correct
36 Correct 3652 ms 336 KB Output is correct
37 Correct 3701 ms 336 KB Output is correct
38 Correct 3812 ms 336 KB Output is correct
39 Correct 3720 ms 336 KB Output is correct
40 Correct 3701 ms 336 KB Output is correct
41 Correct 3653 ms 336 KB Output is correct
42 Correct 2359 ms 336 KB Output is correct
43 Correct 1806 ms 336 KB Output is correct
44 Correct 3799 ms 336 KB Output is correct
45 Correct 1787 ms 336 KB Output is correct
46 Correct 3597 ms 336 KB Output is correct
47 Correct 3602 ms 336 KB Output is correct
48 Correct 3561 ms 336 KB Output is correct
49 Correct 1738 ms 336 KB Output is correct
50 Correct 1806 ms 336 KB Output is correct
51 Correct 3776 ms 336 KB Output is correct
52 Correct 3701 ms 336 KB Output is correct