답안 #1074666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074666 2024-08-25T11:57:12 Z DeathIsAwe Hotter Colder (IOI10_hottercolder) C++17
76.7241 / 100
437 ms 8188 KB
#include "grader.h"
#include <iostream>
#include <vector>
using namespace std;


int destroy(int top, int bottom, int previous) {
   //cout << top << ' ' << bottom << '\n';
   if (top - bottom == 0) {
      return top;
   } else if (top - bottom == 1) {
      int sussy, ans;
      if (previous == -1) {
         Guess(top); sussy = Guess(bottom);
      }
      if (sussy == 1) {
         ans = bottom;
      } else {
         ans = top;
      }
      return ans;
   }
   int mid = (top + bottom) / 2;
   int midleft = (bottom + mid) / 2;
   int midright = (mid + 1 + top) / 2;
   if (previous == -1) {
      int midleftans = Guess(midleft), midrightans = Guess(midright);
      if (midrightans == 0) {
         return (midleft + midright) / 2;
      } else  if (midrightans == 1) {
         return destroy(top, mid + 1, -1);
      } else {
         if ((midleft + midright) % 2 == 0) {
            return destroy(mid - 1, bottom, -1);
         }
         return destroy(mid, bottom, -1);
      }
   }
}


int HC(int n){
   int ans = destroy(n, 1, -1);
   return ans;
}

Compilation message

hottercolder.cpp: In function 'int destroy(int, int, int)':
hottercolder.cpp:27:11: warning: unused variable 'midleftans' [-Wunused-variable]
   27 |       int midleftans = Guess(midleft), midrightans = Guess(midright);
      |           ^~~~~~~~~~
hottercolder.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
hottercolder.cpp:16:7: warning: 'sussy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |       if (sussy == 1) {
      |       ^~
# 결과 실행 시간 메모리 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 Correct 18 ms 6772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 437 ms 8188 KB Output is partially correct - alpha = 0.068965517241