Submission #554854

# Submission time Handle Problem Language Result Execution time Memory
554854 2022-04-29T13:56:34 Z kevinxiehk Hotter Colder (IOI10_hottercolder) C++17
81 / 100
635 ms 8104 KB
#include <bits/stdc++.h>
#include "grader.h"
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
using namespace std;
 
int Guess (int x);
int last = 1;
int ans;
int cnt = 0;
// int Guess (int x) {
//     cnt++;
//     // cout << x << '\n';
//     if(abs(last - ans) == abs(x - ans)) return 0;
//     else if(abs(last - ans) > abs(x - ans)) return 1;
//     return -1;
// }

int HC(int n){
    int l = 1, r = n;
    last = 1;
    Guess(1);
    while(l < r) {
        // cout << l << ' ' << r << '\n';
        // if(last != l && last != r) {
        //     Guess(l); last = l;
        // }
        int mid = (l + r) / 2;
        int now = mid * 2 - last;
        if(now == last) now++;
        now = min(now, n); now = max(now, 1);

        int k = Guess(now);
        // last = l ^ r ^ last;
        if(k == 0) {
            return (last + now) / 2;
        }
        else if((k == 1 && now > last) || (k == -1 && now < last)) {
            l = max(l, (last + now) / 2 + 1);
        }
        else {
            r = min(r, (last + now + 1) / 2 - 1);
        }
        last = now;
    }
    return l;
}

// int main() {
//     int mx = 0;
//     for(int i = 1; i <= 500; i++) {
//         cnt = 0;
//         ans = i;
//         if(HC(500) != i) cout << i << '\n';
//         mx = max(mx, cnt);
//     }
//     cout << mx << '\n';
// }
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 635 ms 8104 KB Output is partially correct - alpha = 0.259259259259