Submission #1005714

# Submission time Handle Problem Language Result Execution time Memory
1005714 2024-06-22T22:14:30 Z SuPythony Mađioničar (COI22_madionicar) C++17
0 / 100
1152 ms 408 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n; cin>>n;
    int ans1=1;
    for (int i=1; i<=n; i++) {
        int l=i-(ans1+2)/2,r=i+(ans1+2)/2;
        if (l<1||r>n) continue;
        cout<<"? "<<l<<" "<<r<<endl;
        cout.flush();
        int a; cin>>a;
        if (a) {
            ans1=max(ans1,r-l+1);
            while (true) {
                l--; r++;
                if (l<1||r>n) break;
                cout<<"? "<<l<<" "<<r<<endl;
                cout.flush();
                cin>>a;
                if (!a) break;
            }
        }
    }
    int ans2=0;
    for (int i=1; i<=n; i++) {
        int l=i-(ans2+2)/2+1,r=i+(ans2+2)/2;
        if (l<1||r>n) continue;
        cout<<"? "<<l<<" "<<r<<endl;
        cout.flush();
        int a; cin>>a;
        if (a) {
            ans2=max(ans2,r-l+1);
            while (true) {
                l--; r++;
                if (l<1||r>n) break;
                cout<<"? "<<l<<" "<<r<<endl;
                cout.flush();
                cin>>a;
                if (!a) break;
            }
        }
    }
    cout<<"! "<<max(ans1,ans2)<<endl;
    cout.flush();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 344 KB L = 25, expected 30
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 344 KB L = 25, expected 30
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1152 ms 408 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 344 KB L = 25, expected 30
2 Halted 0 ms 0 KB -