Submission #416531

# Submission time Handle Problem Language Result Execution time Memory
416531 2021-06-02T14:51:14 Z nicolaalexandra Colors (BOI20_colors) C++14
0 / 100
1 ms 280 KB
#include <bits/stdc++.h>

using namespace std;

long long n,maxi,i;

int query (long long x){
    int ans;
    cout<<"? "<<x<<endl;
    cin>>ans;
    return ans;
}

int main (){

    cin>>n;

    /// incerc sa aleg optim punctul de start

    long long st = 1, dr = n-1, pas = 0, sum = 0, sum2 = n, Left = 0, Right = n;
    while (st <= dr){
        long long mid = (st+dr)>>1;

        pas++;
        if (pas % 2){
            sum2 -= mid, sum -= mid;

            Right = min (Right,sum2);

        } else {
            sum2 += mid, sum += mid;

            Left = max (Left,sum+1);
        }

        st = mid+1;
    }


    long long x = Left, c = 0;
    query(x);
    st = 1, dr = n-1, pas = 0;
    while (st <= dr){
        long long mid = (st+dr)>>1;
        pas++;
        if (pas % 2)
            x += mid;
        else x -= mid;

        int ans = query (x);
        if (!ans){
            c = mid;
            st = mid+1;
        } else dr = mid-1;
    }

    cout<<"= "<<c+1<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (7 queries)
3 Correct 1 ms 200 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (5 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (6 queries)
9 Correct 1 ms 200 KB OK (7 queries)
10 Correct 1 ms 200 KB OK (4 queries)
11 Correct 0 ms 200 KB OK (5 queries)
12 Correct 1 ms 200 KB OK (6 queries)
13 Correct 1 ms 200 KB OK (7 queries)
14 Correct 1 ms 200 KB OK (7 queries)
15 Correct 0 ms 200 KB OK (7 queries)
16 Correct 1 ms 200 KB OK (7 queries)
17 Correct 1 ms 200 KB OK (7 queries)
18 Correct 1 ms 200 KB OK (6 queries)
19 Correct 0 ms 200 KB OK (6 queries)
20 Correct 1 ms 200 KB OK (7 queries)
21 Correct 0 ms 200 KB OK (7 queries)
22 Runtime error 0 ms 280 KB Execution killed with signal 13
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (7 queries)
3 Correct 1 ms 200 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (5 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (6 queries)
9 Correct 1 ms 200 KB OK (7 queries)
10 Correct 1 ms 200 KB OK (4 queries)
11 Correct 0 ms 200 KB OK (5 queries)
12 Correct 1 ms 200 KB OK (6 queries)
13 Correct 1 ms 200 KB OK (7 queries)
14 Correct 1 ms 200 KB OK (7 queries)
15 Correct 0 ms 200 KB OK (7 queries)
16 Correct 1 ms 200 KB OK (7 queries)
17 Correct 1 ms 200 KB OK (7 queries)
18 Correct 1 ms 200 KB OK (6 queries)
19 Correct 0 ms 200 KB OK (6 queries)
20 Correct 1 ms 200 KB OK (7 queries)
21 Correct 0 ms 200 KB OK (7 queries)
22 Runtime error 0 ms 280 KB Execution killed with signal 13
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (7 queries)
3 Correct 1 ms 200 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (5 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (6 queries)
9 Correct 1 ms 200 KB OK (7 queries)
10 Correct 1 ms 200 KB OK (4 queries)
11 Correct 0 ms 200 KB OK (5 queries)
12 Correct 1 ms 200 KB OK (6 queries)
13 Correct 1 ms 200 KB OK (7 queries)
14 Correct 1 ms 200 KB OK (7 queries)
15 Correct 0 ms 200 KB OK (7 queries)
16 Correct 1 ms 200 KB OK (7 queries)
17 Correct 1 ms 200 KB OK (7 queries)
18 Correct 1 ms 200 KB OK (6 queries)
19 Correct 0 ms 200 KB OK (6 queries)
20 Correct 1 ms 200 KB OK (7 queries)
21 Correct 0 ms 200 KB OK (7 queries)
22 Runtime error 0 ms 280 KB Execution killed with signal 13
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (7 queries)
3 Correct 1 ms 200 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (5 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (6 queries)
9 Correct 1 ms 200 KB OK (7 queries)
10 Correct 1 ms 200 KB OK (4 queries)
11 Correct 0 ms 200 KB OK (5 queries)
12 Correct 1 ms 200 KB OK (6 queries)
13 Correct 1 ms 200 KB OK (7 queries)
14 Correct 1 ms 200 KB OK (7 queries)
15 Correct 0 ms 200 KB OK (7 queries)
16 Correct 1 ms 200 KB OK (7 queries)
17 Correct 1 ms 200 KB OK (7 queries)
18 Correct 1 ms 200 KB OK (6 queries)
19 Correct 0 ms 200 KB OK (6 queries)
20 Correct 1 ms 200 KB OK (7 queries)
21 Correct 0 ms 200 KB OK (7 queries)
22 Runtime error 0 ms 280 KB Execution killed with signal 13
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (7 queries)
3 Correct 1 ms 200 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (5 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (6 queries)
9 Correct 1 ms 200 KB OK (7 queries)
10 Correct 1 ms 200 KB OK (4 queries)
11 Correct 0 ms 200 KB OK (5 queries)
12 Correct 1 ms 200 KB OK (6 queries)
13 Correct 1 ms 200 KB OK (7 queries)
14 Correct 1 ms 200 KB OK (7 queries)
15 Correct 0 ms 200 KB OK (7 queries)
16 Correct 1 ms 200 KB OK (7 queries)
17 Correct 1 ms 200 KB OK (7 queries)
18 Correct 1 ms 200 KB OK (6 queries)
19 Correct 0 ms 200 KB OK (6 queries)
20 Correct 1 ms 200 KB OK (7 queries)
21 Correct 0 ms 200 KB OK (7 queries)
22 Runtime error 0 ms 280 KB Execution killed with signal 13
23 Halted 0 ms 0 KB -