답안 #119627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119627 2019-06-21T13:30:33 Z DodgeBallMan Hotter Colder (IOI10_hottercolder) C++14
컴파일 오류
0 ms 0 KB
#include "grader.h"
#include <bits/stdc++.h>
 
using namespace std;
 
// int Guess( int now ) {
//     printf("%d\n",now);
//     int ret;
//     scanf("%d",ret);
//     return ret;
// }

int HC( int n ){
    Guess( 1 );
    int l = 1, r = n, prev = 1, ver = 1;
    while( l < r ) {
        if( ver == 0 ) {
            int now = Guess( l );
            int mid = ( l + r ) >> 1;
            if( now == 0 ) return ( prev + l ) / 2;
            else if( now == 1 ) {
                r = ( l + r + 1 ) / 2 - 1;
                prev = l, ver = 0;
            } 
            else {
                l = mid + 1;
                Guess( prev );
            }
        }
        else {
            int now = Guess( r );
            int mid = ( l + r ) >> 1;
            if( now == 0 ) return ( prev + r ) / 2;
            else if( now == 1 ) {
                l = mid + 1;
                pre = r, last = 1;
            } 
            else {
                r = ( l + r + 1 ) / 2 - 1;
                Guess( pre );
            }
        }
    }
    return l;
}

// int main() {
//     HC( 100 );
// }

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:36:17: error: 'pre' was not declared in this scope
                 pre = r, last = 1;
                 ^~~
hottercolder.cpp:36:17: note: suggested alternative: 'prev'
                 pre = r, last = 1;
                 ^~~
                 prev
hottercolder.cpp:36:26: error: 'last' was not declared in this scope
                 pre = r, last = 1;
                          ^~~~
hottercolder.cpp:36:26: note: suggested alternative: 'wait'
                 pre = r, last = 1;
                          ^~~~
                          wait
hottercolder.cpp:40:24: error: 'pre' was not declared in this scope
                 Guess( pre );
                        ^~~
hottercolder.cpp:40:24: note: suggested alternative: 'prev'
                 Guess( pre );
                        ^~~
                        prev