Submission #59537

# Submission time Handle Problem Language Result Execution time Memory
59537 2018-07-22T09:23:14 Z aquablitz11 Hotter Colder (IOI10_hottercolder) C++14
89 / 100
849 ms 8212 KB
#include <cassert>
#include <random>
#include "grader.h"
using namespace std;

mt19937 rd(31415926);
uniform_int_distribution<int> dis(0, 1);

int HC(int n)
{
    int l = 1;
    int r = n;
    Guess(1);
    int p = 1;
    while (l < r) {
        int z = r-l+1;
        int res, side;
        if (p == l) {
            res = Guess(p = r), side = 0;
        } else if (p == r) {
            res = Guess(p = l), side = 1;
        } else if (p < l) {
            int q = r+(l-p);
            if (q <= n) {
                res = Guess(p = q);
                side = 0;
            } else {
                Guess(p = (r <= n/2 ? r : l));
                continue;
            }
        } else if (p > r) {
            int q = l-(p-r);
            if (q >= 1) {
                res = Guess(p = q);
                side = 1;
            } else {
                Guess(p = (r <= n/2 ? r : l));
                continue;
            }
        } else {
            assert(false);
        }

        int m = (l+r)/2;
        if (side == 0) {
            if (z % 2 == 0) {
                if (res == 1) l = m+1;
                else if (res == -1) r = m;
                else assert(false);
            } else {
                if (res == 1) l = m+1;
                else if (res == -1) r = m-1;
                else l = r = m;
            }
        } else {
            if (z % 2 == 0) {
                if (res == 1) r = m;
                else if (res == -1) l = m+1;
                else assert(false);
            } else {
                if (res == 1) r = m-1;
                else if (res == -1) l = m+1;
                else l = r = m;
            }
        }
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 849 ms 8212 KB Output is partially correct - alpha = 0.555555555556