Submission #930522

# Submission time Handle Problem Language Result Execution time Memory
930522 2024-02-20T05:33:24 Z UmairAhmadMirza Colors (BOI20_colors) C++14
0 / 100
1 ms 344 KB
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    if(n==1){
        cout<<"= "<<1<<endl;
        return 0;
    }
    bool r=0;
    int mid=(n/2)+1;
    cout<<"? "<<mid<<endl;
    cin>>r;
    cout<<"? "<<1<<endl;
    cin>>r;
    if(r==0){
        int a=1,b=n+1;
        int i=0;
        while((b-a)>mid){
            if(i){
                a++;
                cout<<"? "<<a<<endl;
                cin>>r;
                if(r==0)
                    break;
            }
            else{
                b--;
                cout<<"? "<<b<<endl;
                cin>>r;
                if(r==0)
                    break;
            }
            i^=1;
        }
        cout<<"= "<<(b-a)+!r<<endl;
    }
    else{
        int a=1,b=mid;
        if(b==2){
            cout<<"= "<<1<<endl;
            return 0;
        }
        for(int i=2;i<mid;i++){
            if(i%2){
                a++;
                cout<<"? "<<a<<endl;
                cin>>r;
                if(r==0)
                    break;
            }
            else{
                b--;
                cout<<"? "<<b<<endl;
                cin>>r;
                if(r==0)
                    break;
            }
        }
        cout<<"= "<<(b-a)+!r<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (7 queries)
3 Correct 0 ms 344 KB OK (6 queries)
4 Correct 0 ms 344 KB OK (14 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (27 queries)
7 Correct 0 ms 344 KB OK (18 queries)
8 Correct 0 ms 344 KB OK (8 queries)
9 Correct 0 ms 344 KB OK (10 queries)
10 Correct 0 ms 344 KB OK (6 queries)
11 Correct 1 ms 344 KB OK (5 queries)
12 Correct 0 ms 344 KB OK (6 queries)
13 Correct 0 ms 344 KB OK (12 queries)
14 Correct 0 ms 344 KB OK (17 queries)
15 Correct 0 ms 344 KB OK (12 queries)
16 Correct 0 ms 344 KB OK (8 queries)
17 Correct 0 ms 344 KB OK (3 queries)
18 Correct 1 ms 344 KB OK (17 queries)
19 Correct 0 ms 344 KB OK (4 queries)
20 Correct 0 ms 344 KB OK (32 queries)
21 Correct 0 ms 344 KB OK (10 queries)
22 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to 3, violates the range [1, 2]
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (7 queries)
3 Correct 0 ms 344 KB OK (6 queries)
4 Correct 0 ms 344 KB OK (14 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (27 queries)
7 Correct 0 ms 344 KB OK (18 queries)
8 Correct 0 ms 344 KB OK (8 queries)
9 Correct 0 ms 344 KB OK (10 queries)
10 Correct 0 ms 344 KB OK (6 queries)
11 Correct 1 ms 344 KB OK (5 queries)
12 Correct 0 ms 344 KB OK (6 queries)
13 Correct 0 ms 344 KB OK (12 queries)
14 Correct 0 ms 344 KB OK (17 queries)
15 Correct 0 ms 344 KB OK (12 queries)
16 Correct 0 ms 344 KB OK (8 queries)
17 Correct 0 ms 344 KB OK (3 queries)
18 Correct 1 ms 344 KB OK (17 queries)
19 Correct 0 ms 344 KB OK (4 queries)
20 Correct 0 ms 344 KB OK (32 queries)
21 Correct 0 ms 344 KB OK (10 queries)
22 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to 3, violates the range [1, 2]
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (7 queries)
3 Correct 0 ms 344 KB OK (6 queries)
4 Correct 0 ms 344 KB OK (14 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (27 queries)
7 Correct 0 ms 344 KB OK (18 queries)
8 Correct 0 ms 344 KB OK (8 queries)
9 Correct 0 ms 344 KB OK (10 queries)
10 Correct 0 ms 344 KB OK (6 queries)
11 Correct 1 ms 344 KB OK (5 queries)
12 Correct 0 ms 344 KB OK (6 queries)
13 Correct 0 ms 344 KB OK (12 queries)
14 Correct 0 ms 344 KB OK (17 queries)
15 Correct 0 ms 344 KB OK (12 queries)
16 Correct 0 ms 344 KB OK (8 queries)
17 Correct 0 ms 344 KB OK (3 queries)
18 Correct 1 ms 344 KB OK (17 queries)
19 Correct 0 ms 344 KB OK (4 queries)
20 Correct 0 ms 344 KB OK (32 queries)
21 Correct 0 ms 344 KB OK (10 queries)
22 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to 3, violates the range [1, 2]
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (7 queries)
3 Correct 0 ms 344 KB OK (6 queries)
4 Correct 0 ms 344 KB OK (14 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (27 queries)
7 Correct 0 ms 344 KB OK (18 queries)
8 Correct 0 ms 344 KB OK (8 queries)
9 Correct 0 ms 344 KB OK (10 queries)
10 Correct 0 ms 344 KB OK (6 queries)
11 Correct 1 ms 344 KB OK (5 queries)
12 Correct 0 ms 344 KB OK (6 queries)
13 Correct 0 ms 344 KB OK (12 queries)
14 Correct 0 ms 344 KB OK (17 queries)
15 Correct 0 ms 344 KB OK (12 queries)
16 Correct 0 ms 344 KB OK (8 queries)
17 Correct 0 ms 344 KB OK (3 queries)
18 Correct 1 ms 344 KB OK (17 queries)
19 Correct 0 ms 344 KB OK (4 queries)
20 Correct 0 ms 344 KB OK (32 queries)
21 Correct 0 ms 344 KB OK (10 queries)
22 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to 3, violates the range [1, 2]
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (7 queries)
3 Correct 0 ms 344 KB OK (6 queries)
4 Correct 0 ms 344 KB OK (14 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (27 queries)
7 Correct 0 ms 344 KB OK (18 queries)
8 Correct 0 ms 344 KB OK (8 queries)
9 Correct 0 ms 344 KB OK (10 queries)
10 Correct 0 ms 344 KB OK (6 queries)
11 Correct 1 ms 344 KB OK (5 queries)
12 Correct 0 ms 344 KB OK (6 queries)
13 Correct 0 ms 344 KB OK (12 queries)
14 Correct 0 ms 344 KB OK (17 queries)
15 Correct 0 ms 344 KB OK (12 queries)
16 Correct 0 ms 344 KB OK (8 queries)
17 Correct 0 ms 344 KB OK (3 queries)
18 Correct 1 ms 344 KB OK (17 queries)
19 Correct 0 ms 344 KB OK (4 queries)
20 Correct 0 ms 344 KB OK (32 queries)
21 Correct 0 ms 344 KB OK (10 queries)
22 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to 3, violates the range [1, 2]
23 Halted 0 ms 0 KB -