Submission #413656

#TimeUsernameProblemLanguageResultExecution timeMemory
413656Ruxandra985Colors (BOI20_colors)C++14
100 / 100
3 ms328 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //FILE *fin = fopen ("a.in" , "r");

    long long n , c , now , x , sol = 0 , eq , p2 , st , dr , mid , dir , inc;

    //fscanf (fin,"%lld%lld",&n,&c);
    cin >> n;


    now = n;
    dir = -1;
    inc = n;

    st = 1;
    dr = n - 1;
    while (st <= dr){

        mid = (st + dr) / 2;

        now = now + dir * mid;
        dir = -dir;

        if (now >= n){
            inc = inc - (now - n);
            now = n;
        }

        st = mid + 1; /// worst case

    }


    cout << "? " << inc << endl;
    cin >> x;

    now = inc;

    st = 1;
    dr = n - 1;
    dir = -1;

    while (st <= dr){
        mid = (st + dr)/2;

        now = now + mid * dir;
        dir = -dir;
        cout << "? " << now << endl;
        cin >> x;

        if (x)
            dr = mid - 1;
        else st = mid + 1;

    }

    cout << "= " << st << endl;
    return 0;
}

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:9:19: warning: unused variable 'c' [-Wunused-variable]
    9 |     long long n , c , now , x , sol = 0 , eq , p2 , st , dr , mid , dir , inc;
      |                   ^
Colors.cpp:9:33: warning: unused variable 'sol' [-Wunused-variable]
    9 |     long long n , c , now , x , sol = 0 , eq , p2 , st , dr , mid , dir , inc;
      |                                 ^~~
Colors.cpp:9:43: warning: unused variable 'eq' [-Wunused-variable]
    9 |     long long n , c , now , x , sol = 0 , eq , p2 , st , dr , mid , dir , inc;
      |                                           ^~
Colors.cpp:9:48: warning: unused variable 'p2' [-Wunused-variable]
    9 |     long long n , c , now , x , sol = 0 , eq , p2 , st , dr , mid , dir , inc;
      |                                                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...