Submission #303469

# Submission time Handle Problem Language Result Execution time Memory
303469 2020-09-20T10:43:24 Z tatyam Hotter Colder (IOI10_hottercolder) C++17
92 / 100
778 ms 24568 KB
#include <algorithm>
using std::clamp;

int Guess(int G);

int HC(int N){
    if(N == 1) return 1;
    int l = 1, r = N, p = (l + r) / 2 + 1;
    Guess(p);
    while(l < r){
        const int p2 = [&]{
            if(p == 1){
                return clamp((l + l + l + r + 1) / 2 - p, 1, N);
            }
            if(p == N){
                return clamp((r + r + r + l) / 2 - p, 1, N);
            }
            int ans = clamp(l + r - p, 1, N);
            if(ans == p){
                if(N - r > l - 1) ans--;
                else ans++;
            }
            return ans;
        }();
        int ans = Guess(p2);
        if(ans == 0) return (p + p2) / 2;
        if(ans == 1){
            if(p2 < p) r = (p + p2 - 1) / 2;
            else l = (p + p2 + 2) / 2;
        }
        else{
            if(p2 < p) l = (p + p2 + 2) / 2;
            else r = (p + p2 - 1) / 2;
        }
        p = p2;
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 778 ms 24568 KB Output is partially correct - alpha = 0.666666666667