답안 #231495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231495 2020-05-13T19:31:53 Z muhammad_hokimiyon Hotter Colder (IOI10_hottercolder) C++14
52 / 100
759 ms 8568 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 - 1 < ls1 ){
            l = m;
            continue;
        }
        if( x1 == -1 && m - 1 > ls1 ){
            r = m;
            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;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1280 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 759 ms 8568 KB Output is partially correct - alpha = 0.068965517241