Submission #1274113

#TimeUsernameProblemLanguageResultExecution timeMemory
1274113oswaldzzMađioničar (COI22_madionicar)C++20
0 / 100
482 ms424 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define nl endl #define hehe ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL) ; // const int mod = 998244353; const int mod = 1e9+7; const int M = 2e5+5; int gas(int a, int b){ cout << "? " << a << ' ' << b << nl; cout.flush(); int x; if(!(cin >> x)){ exit(0); } return x; } void solve(){ int n; cin >> n; if(n == 1){ cout << "! " << 1 << nl; return; } int ans = 1; for(int i = 2; i <= n-1; i++){ int l = i, r = i; while(l > 1 && r < n){ if(gas(l-1, r+1) == 1){ l--; r++; } else break; } ans = max(ans, r - l + 1); } for(int i = 1; i <= n-1; i++){ int l = i, r = i+1; if(gas(l, r) != 1) continue; while(l > 1 && r < n){ if(gas(l-1, r+1) == 1){ l--; r++; } else break; } ans = max(ans, r - l + 1); } cout << "! " << ans << nl; } signed main(){ hehe // int t; cin >> t; int t = 1; while(t--){ solve(); } return 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...