Submission #556704

# Submission time Handle Problem Language Result Execution time Memory
556704 2022-05-03T17:43:02 Z MohamedFaresNebili Hotter Colder (IOI10_hottercolder) C++14
85 / 100
576 ms 9108 KB
#include <bits/stdc++.h>
#include "grader.h"

        using namespace std;

        using ll = long long;
        using ii = pair<ll, ll>;
        using vi = vector<int>;

        #define ff first
        #define ss second
        #define pb push_back
        #define all(x) (x).begin(), (x).end()
        #define lb lower_bound
        /// #define int ll

        const int oo = 1e9 + 7;

        int Guess(int v);

        int HC(int N) {
            int lo = 1, hi = N, pr = (2 * N - 2) / 3;
            pr = max(1, pr); pr = min(N, pr);
            Guess(pr);
            while(lo < hi) {
                int to = (lo + hi) / 2;

              	if(to == pr && to - 1 >= lo) to--;
              	if(to == pr && to + 1 <= hi) to++;
              	if(to == pr) return to;

                int r = Guess(to), md = abs(to - pr);
                if(md & 1) md++;

                if(r == 0) return (to + pr) / 2;
                else if((r == 1 && to > pr) || (r == -1 && to < pr))
                    lo = max(lo, (to + pr) / 2 + 1);
                else hi = min(hi, (to + pr + 1) / 2 - 1);
                pr = to;
            }
            return lo;
        }
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 576 ms 9108 KB Output is partially correct - alpha = 0.400000000000