Submission #231496

# Submission time Handle Problem Language Result Execution time Memory
231496 2020-05-13T19:34:11 Z muhammad_hokimiyon Hotter Colder (IOI10_hottercolder) C++14
78 / 100
732 ms 8184 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

/*int ls;
int num = 20;

int Guess( int x )
{
    int x1 = abs(num - x);
    int x2 = abs(num - ls);
    ls = x;
    if( x1 < x2 )return 1;
    if( x1 > x2 )return -1;
    return 0;
}*/

int HC(int nn)
{
    int Q = 0;
    int ls1 = 0;
    int ls2 = 0;
    int l = 1 , r = nn;
    while( l < r ){
        ls1 = ls2;
        //cout << "\n";
        int m = (l + r) / 2;
        if( l == 1 && r == 2 ){
            int x1 = Guess(1);
            int x2 = Guess(2);
            if( x2 == 1 )return 2;
            return 1;
        }
        //cout << l << " " << r << " " << m - 1 << " ";
        int x1 = Guess(m - 1);
        ls2 = m - 1;
        if( x1 == -1 && m < ls1 ){
            l = m + 1;
            continue;
        }
        if( x1 == -1 && m - 1 > ls1 ){
            r = m - 1;
            continue;
        }
        //cout << m + 1;
        ls2 = m + 1;
        int x2 = Guess(m + 1);
        if( x2 == 0 ){
            return m;
        }
        if( x2 == 1 )l = m + 1;
        else r = m - 1;
    }
    return l;
}

/*int main()
{
    int n;
    cin >> n;
    cout << "\n" << HC(n);
}*/

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:30:17: warning: unused variable 'x1' [-Wunused-variable]
             int x1 = Guess(1);
                 ^~
hottercolder.cpp:21:9: warning: unused variable 'Q' [-Wunused-variable]
     int Q = 0;
         ^
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 732 ms 8184 KB Output is partially correct - alpha = 0.103448275862