Submission #642282

# Submission time Handle Problem Language Result Execution time Memory
642282 2022-09-19T07:31:55 Z berr Colors (BOI20_colors) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l, r, ans, c;

void query(int x)
{
    cout<<"? "<<x<<endl;

    cin>>ans;
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    int x; cin>>x;

        l=n/3, r=l;

    query(l);
    int t=1;

    for(int i=62; i>=0; i--)
    {
        if((1LL<<i)+r<=n&&t&2==1)
        {
            r+=(1LL<<i);
            query(r);
            if(ans==1)
            {
                l+=min(r-l, 1LL<<i);
            }
            t++;
        }
        else if((1LL<<i)<l)
        {
            l-=(1LL<<i);
            query(l);
            if(ans==1)
            {
                r-=min(r-l, (1LL<<i));
            }
            t++;
        }
        else
        {
            r+=(1LL<<i);
            query(r);
            if(ans==1)
            {
                l+=min(r-l, 1LL<<i);
            }
        }
    }
    cout<<"= "<<abs(l-r)+1<<endl;



}

Compilation message

Colors.cpp: In function 'int32_t main()':
Colors.cpp:27:30: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   27 |         if((1LL<<i)+r<=n&&t&2==1)
      |                             ~^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -