답안 #895210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895210 2023-12-29T15:45:41 Z Irate Hotter Colder (IOI10_hottercolder) C++14
25 / 100
427 ms 8240 KB
#include<bits/stdc++.h>
using namespace std;
int Guess(int n);
// int lastG = -1, X;
// int cnt = 0;
// int Guess(int n){
//     cnt++;
//     // cout << "GUESS: " << last << ", " << n << '\n';
//     if(lastG == -1 || abs(X - lastG) == abs(X - n)){
//         lastG = n;
//         return 0;
//     }
//     if(abs(X - lastG) > abs(X - n)){
//         lastG = n;
//         return 1;
//     }
//     lastG = n;
//     return -1;
// }
int HC(int n){
    int l = 1, r = n, last = 1;
    Guess(1);
    while(l < r){
        int mid = (l + r) >> 1;
        // cout << l << ", " << r << ": " << last << '\n';
        if(last == l){
            int num = Guess(r);
            last = r;
            if(num == -1){
                r = mid;
                last = r;
                Guess(r);
            }
            else if(num == 1){
                l = mid + 1;
            }
            else{
                return (l + r) >> 1;
            }
        }
        else{
            int num = Guess(l);
            last = l;
            if(num == 1){
                r = mid;
            }
            else if(num == -1){
                l = mid + 1;
                last = l;
                Guess(l);
            }
            else return (l + r) >> 1;
        }
    }
    return l;
}
// int main(){
//     int n;
//     cin >> n >> X;
//     int found_num = HC(n);
//     if(X == found_num){
//         cout << "Accepted: " << cnt << '\n';
//     }
//     else{
//         cout << "Wrong guess: " << found_num << '\n';
//     }
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 6776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 427 ms 8240 KB Output isn't correct - alpha = 0.000000000000