답안 #224451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224451 2020-04-17T23:42:44 Z jhnah917 Hotter Colder (IOI10_hottercolder) C++14
75 / 100
1092 ms 262144 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

int sub3(int N){
    int l = 1, r = N;
    while(l < r){
        int m = l + r >> 1;
        int a = Guess(l), b = Guess(r);
        if(b == 1) l = m + 1;
        else if(b == -1) r = l + r - 1 >> 1;
        else return m;
    }
    return l;
}

int HC(int N){
    if(N <= 500) return sub3(N);
    int l = 1, r = N;
    int prv = (l + l + r) / 3; Guess(prv);
    while(l < r){
        int m1 = (l + l + r) / 3, m2 = (l + r + r) / 3;
        int now = abs(prv - m1) < abs(prv - m2) ? m2 : m1;
        int qry = Guess(qry);
        if(qry == 1){
            if(prv < now) l = max(l, prv + now + 1 >> 1);
            else r = min(r, prv + now >> 1);
        }else if(qry == -1){
            if(prv < now) r = min(r, prv + now >> 1);
            else l = max(l, prv + now + 1 >> 1);
        }else return (prv + now >> 1);
    }
    return l;
}

Compilation message

hottercolder.cpp: In function 'int sub3(int)':
hottercolder.cpp:8:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int m = l + r >> 1;
                 ~~^~~
hottercolder.cpp:11:36: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
         else if(b == -1) r = l + r - 1 >> 1;
                              ~~~~~~^~~
hottercolder.cpp:9:13: warning: unused variable 'a' [-Wunused-variable]
         int a = Guess(l), b = Guess(r);
             ^
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:26:48: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             if(prv < now) l = max(l, prv + now + 1 >> 1);
                                      ~~~~~~~~~~^~~
hottercolder.cpp:27:33: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             else r = min(r, prv + now >> 1);
                             ~~~~^~~~~
hottercolder.cpp:29:42: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             if(prv < now) r = min(r, prv + now >> 1);
                                      ~~~~^~~~~
hottercolder.cpp:30:39: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             else l = max(l, prv + now + 1 >> 1);
                             ~~~~~~~~~~^~~
hottercolder.cpp:31:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         }else return (prv + now >> 1);
                       ~~~~^~~~~
hottercolder.cpp:24:28: warning: 'qry' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int qry = Guess(qry);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1092 ms 262144 KB Output isn't correct - alpha = 0.000000000000