답안 #1085971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085971 2024-09-09T08:32:05 Z not_amir Colors (BOI20_colors) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

//#define T

typedef long long ll;

int C;

int ask(ll q){
    static ll bef = 0;
    cout << "? " << q << endl;
    int ans;
    #ifdef T
        cout << (abs(q - bef) < C?ans=0:ans=1) << endl;
        bef = q;
    #else
        cin >> ans;
    #endif
    return ans;
}

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

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

Compilation message

Colors.cpp: In function 'int ask(ll)':
Colors.cpp:11:15: warning: unused variable 'bef' [-Wunused-variable]
   11 |     static ll bef = 0;
      |               ^~~
Colors.cpp: At global scope:
Colors.cpp:11:15: warning: 'bef' defined but not used [-Wunused-variable]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -