Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
42548853 Practice:
hell_hacker
1040D - 126 C++17 (GCC 7-32) Accepted 31 ms 240 KB 2018-09-06 13:50:07 2018-09-06 13:50:07
→ Source
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
using namespace std;

ll n, k;


string query(ll l, ll r){
    cout << l << " " << r << endl;
    fflush(stdout);
    string response;
    cin >> response;
    return response;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    srand(time(NULL));

    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //mt19937 rng((uint64_t) new char);

    cin >> n >> k;
    ll lo = 1, hi = n, ct = 4500;
    while(1){
        if((hi - lo) >= 5LL*k){
            ll mid = (lo + hi) >> 1;
            string s = query(lo, mid);
            if(s == "Bad"){
                return 0;
            }
            else if(s == "Yes"){
                lo = max(1LL, lo - k);
                hi = min(n, mid + k);
            }
            else{
                lo = max(1LL, mid + 1 - k);
                hi = min(n, hi + k);
            }
        }
        else{
            if(hi - lo + 1 <= 0)hi = lo;
            assert(hi - lo + 1 > 0);
            ll random = ( rand() % (hi - lo + 1) ) + lo;
            string s = query(random, random);
            if(s == "Yes"){
                return 0;
            }
            else if(s == "No"){
                lo = max(1LL, lo - k);
                hi = min(n, hi + k);
            }
            else{
                return 0;
            }
        }
    }
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details