답안 #1074126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074126 2024-08-25T08:11:43 Z Hugo1729 Hotter Colder (IOI10_hottercolder) C++11
78.7037 / 100
403 ms 24420 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

int p;

int make_guess(int x){
   int sus = Guess(x);
   // cout << x << ' ' << sus << '\n';
   return sus;
}

int HC(int N){
   // int g = make_guess(1);
   // int h = make_guess(N);
   // if (g == 0) return N/2;
   // if (g < 0) return N/4;
   // if (g > 0) return 3*N/4;

   // cout << N << '\n';

   p=-1;

   int lo=1,hi=N;

   while(lo<hi){
      int mid=(hi+lo)/2;

      if(p==-1){
         int g1 = make_guess(mid),g2=make_guess(mid+1);
         p=mid+1;

         if(g2==1){
            lo=mid+1;
         }else{
            hi=mid;
         }
      }else{
         int query=min(N,max(1,(lo+hi-p)));
         int g=make_guess(query);

         if(g==0){
            // cout << (query+p)/2 << "\n\n";
            return (query+p)/2;
         }
         else if(query<p){
            if(g==1)hi=(p+query)/2;
            else lo=(p+query+1)/2;
         }else{
            if(g==-1)hi=(p+query)/2;
            else lo=(p+query+1)/2;
         }

         p=query;
      }
      // cout << "a: " << lo << ' ' << hi << '\n';
   }

   // cout << lo << "\n\n";

   return lo;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:30:14: warning: unused variable 'g1' [-Wunused-variable]
   30 |          int g1 = make_guess(mid),g2=make_guess(mid+1);
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 403 ms 24420 KB Output is partially correct - alpha = 0.148148148148