Submission #59252

# Submission time Handle Problem Language Result Execution time Memory
59252 2018-07-21T10:40:21 Z TAMREF Hotter Colder (IOI10_hottercolder) C++11
54 / 100
766 ms 8280 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

int Opt3(int b, int w){
    if(w){
        int g = Guess(b);
        return b + 1 - g;
    }else{
        int g = Guess(b+2);
        return b + 1 + g;
    }
}

int Opt4(int b, int w){
    if(w){
        int g = Guess(b+1);
        if(g == 0) return b + 2;
        if(g == -1) return b + 3;
        if(g == 1){
            int h = Guess(b);
            return h == 1 ? b : b + 1;
        }
    }else{
        int g = Guess(b+2);
        if(g == 0) return b + 1;
        if(g == -1) return b;
        if(g == 1){
            int h = Guess(b+3);
            return h == 1 ? b + 3 : b + 2;
        }
    }
}

int Opt6(int b, int w){
    if(w){
        int g = Guess(b + 3);
        if(g == 0) return b + 4;
        if(g == -1) return b + 5;
        if(g == 1) return Opt4(b,1);
    }else{
        int g = Guess(b + 2);
        if(g == 0) return b + 1;
        if(g == -1) return b;
        if(g == 1) return Opt4(b+2, 0);
    }
}

int HC(int N){
    int b[2] = {1,N};
    Guess(b[1]);
    for(int w = 0, r; b[0] < b[1]; w ^= 1){
        if(b[1] - b[0] == 5) return Opt6(b[0], !w);
        if(b[1] - b[0] == 3) return Opt4(b[0], !w);
        if(b[1] - b[0] == 2) return Opt3(b[0], !w);
        r = Guess(b[w]);
        if(N == 0) printf("N = %d, [%d, %d], res = %d\n",N,b[w],b[!w],r);
        if(!r) return (b[0] + b[1]) / 2;
        if(r == -1){
            if(b[1] - b[0] == 5) return Opt6(b[0], w);
            if(b[1] - b[0] == 3) return Opt4(b[0], w);
            if(b[1] - b[0] == 2) return Opt3(b[0], w);
            if(b[1] - b[0] == 1) return b[!w];
            b[w] = (b[0] + b[1]) / 2 + !w;
            Guess(b[w]);
        }
        else{
            if(b[1] - b[0] == 1) return b[w];
            b[!w] = (b[0] + b[1] + w) / 2;
        }
    }
    return b[0];
}

Compilation message

hottercolder.cpp: In function 'int Opt4(int, int)':
hottercolder.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
hottercolder.cpp: In function 'int Opt6(int, int)':
hottercolder.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Partially correct 766 ms 8280 KB Output is partially correct - alpha = 0.153846153846