Submission #59251

# Submission time Handle Problem Language Result Execution time Memory
59251 2018-07-21T10:30:56 Z aquablitz11 Hotter Colder (IOI10_hottercolder) C++14
78 / 100
836 ms 8184 KB
#include <assert.h>
#include "grader.h"

int HC(int n)
{
    int l = 1;
    int r = n;
    int p = 0;
    while (l < r) {
        if (p != l && p != r) {
            Guess(l);
            p = l;
        }
        int z = r-l+1;
        int m = (l+r)/2;
        if (p == l) {
            int res = Guess(r);
            p = r;
            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 {
            int res = Guess(l);
            p = l;
            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 30 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1276 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 836 ms 8184 KB Output is partially correct - alpha = 0.115384615385