답안 #826584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826584 2023-08-15T17:20:07 Z aaron_dcoder Colors (BOI20_colors) C++17
0 / 100
0 ms 208 KB
//todo
//fuck you random io error i am not able to understand

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

bool did_archie_notice(ll col) {
    cout << "? " << col << endl;
    int ans;
    cin >> ans;
    cout << endl;
    return (ans == 1);
}


int offset(ll N) {
    ll minimum_possible_value_C = 1ll;
    ll curren_hair_color = N/3ll;
    ll next_direc = 1ll;
    ll next_check = -1;
    ll prevn_check;
    do {
        ll to_check = (N+minimum_possible_value_C)/2ll;
        ll oldhaircolor = curren_hair_color;
        prevn_check = next_check;
        next_check= curren_hair_color + next_direc*to_check;
        curren_hair_color = next_check;
        minimum_possible_value_C = abs(oldhaircolor-curren_hair_color)+1ll;
        next_direc *= -1ll;
        //cout << "\nnextc" << next_check;
        
    } while (minimum_possible_value_C!=N);
    return 1-min(next_check,prevn_check);
}


int main() {

    ll N;
    cin >> N;

    set<ll> used_up;
    ll curren_hair_color = N/3ll +offset(N);
    did_archie_notice(curren_hair_color);
    
    ll maximum_possible_value_C = N;
    ll minimum_possible_value_C = 1ll;

    ll next_direc = 1ll;

    while (maximum_possible_value_C!=minimum_possible_value_C) {
        //cerr << "max pv:" << maximum_possible_value_C << ",min pv:" << minimum_possible_value_C << " ,haircol:" << curren_hair_color << "\n";
        ll to_check = (maximum_possible_value_C+minimum_possible_value_C)/2ll;
        ll oldhaircolor = curren_hair_color;
        bool hasnoticed = true;
        for (ll chk_disp = 0; ; chk_disp++) {
            ll next_check= curren_hair_color + next_direc*(to_check-chk_disp);
            if ((to_check-chk_disp) >= maximum_possible_value_C || (to_check-chk_disp) < minimum_possible_value_C) {
                throw exception();
            }
            if (used_up.count(next_check)==0) {
                used_up.insert(next_check);
                hasnoticed = did_archie_notice(next_check);
                curren_hair_color = next_check;
                break;
            }
            next_check= curren_hair_color + next_direc*(to_check+chk_disp);
            if ((to_check+chk_disp) >= maximum_possible_value_C || (to_check+chk_disp) < minimum_possible_value_C) {
                throw exception();
            }
            if (used_up.count(next_check)==0) {
                used_up.insert(next_check);
                hasnoticed = did_archie_notice(next_check);
                curren_hair_color = next_check;
                break;
            }
        }
        if (hasnoticed) {
            maximum_possible_value_C = abs(oldhaircolor-curren_hair_color);
        }
        else {
            minimum_possible_value_C = abs(oldhaircolor-curren_hair_color)+1ll;
        }
        next_direc *= -1ll;
    }

    cout << "= " << maximum_possible_value_C << endl;
    
}
    
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -