제출 #1086002

#제출 시각아이디문제언어결과실행 시간메모리
1086002not_amirColors (BOI20_colors)C++14
100 / 100
1 ms600 KiB
#include <bits/stdc++.h>
using namespace std;

#define T

typedef long long ll;

int ask(ll q){
    static ll bef = 0;
    cout << "? " << q << endl;
    int ans;
    cin >> ans;
    return ans;
}

ll solve(ll n, ll c, ll add, bool dir){
    if(n == 1)
        return 1 + add;
    ll diff = n/2 + add;
    ll q = dir?c+diff:c-diff;
    if(ask(q))
        return solve(n/2, q, add, !dir);
    else
        return solve((n+1)/2, q, add + n/2, !dir);
}

ll start(ll n){
    if(n == 2)
        return 1;
    return  (n + 1)/2  + 1 - start((n + 1)/2);
}

int main(){
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
    ll n;
    cin >> n;
    ll c = start(n);
    ask(c);
    ll ans = solve(n, c, 0, 1);
    cout << "= " << ans;
}

컴파일 시 표준 에러 (stderr) 메시지

Colors.cpp: In function 'int ask(ll)':
Colors.cpp:9:15: warning: unused variable 'bef' [-Wunused-variable]
    9 |     static ll bef = 0;
      |               ^~~
Colors.cpp: At global scope:
Colors.cpp:9:15: warning: 'bef' defined but not used [-Wunused-variable]
#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...