Submission #1027030

# Submission time Handle Problem Language Result Execution time Memory
1027030 2024-07-18T19:02:38 Z VMaksimoski008 Mađioničar (COI22_madionicar) C++17
0 / 100
1228 ms 12900 KB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

map<pii, int> mp;

int query(int l, int r) {
    if(mp.count({ l, r })) return mp[{ l, r }];
    cout << "? " << l << " " << r << endl;
    int x;
    cin >> x;
    return mp[{ l, r }] = x;
}

signed main() {
    int n;
    cin >> n;

    int l=2, r=n, ans=1;
    while(l <= r) {
        int mid = (l + r) / 2, ok = 0;
        for(int i=1; i+mid-1<=n; i++) {
            if(query(i, i+mid-1)) {
                ok = 1;
                break;
            }
        }

        if(ok) ans = mid, l = mid + 1;
        else r = mid - 1;
    }

    cout << "! " << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 490 ms 5032 KB Output is correct
2 Incorrect 479 ms 5660 KB L = 5, expected 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 490 ms 5032 KB Output is correct
2 Incorrect 479 ms 5660 KB L = 5, expected 7
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1228 ms 12900 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 490 ms 5032 KB Output is correct
2 Incorrect 479 ms 5660 KB L = 5, expected 7
3 Halted 0 ms 0 KB -