답안 #676389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676389 2022-12-30T15:30:16 Z dooompy Colors (BOI20_colors) C++17
0 / 100
1 ms 256 KB
#include "bits/stdc++.h"

using namespace std;

void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}

#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif

using ll = long long;

int res(ll loc) {
    cout << "? " << loc << endl;
    
    int r; cin >> r;
    return r;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);
    ll n; cin >> n;

    ll l = 1, r = n - 1, ans = n;

    vector<ll> dist;
    
    while (l <= r) {
        ll m = (l + r) / 2;
        
        dist.push_back(m);
        l = m  +1;
    }
    
    ll loc = 1;
    ll flag = 1;
    
    for (int i = dist.size() - 1; ~i; i--) {
        loc += flag * dist[i];
        flag = -flag;
    }
    
    res(loc);
    
    while (l <= r) {
        ll m = (l + r) / 2;
        
        loc += flag * m;
        flag = -flag;
        
        if (res(loc) == 1) {
            ans = m;
            r = m - 1;
        } else l = m + 1;
    }
    
    cout << "= " << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Wrong guess
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Wrong guess
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Wrong guess
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Wrong guess
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Wrong guess
2 Halted 0 ms 0 KB -