Submission #173048

# Submission time Handle Problem Language Result Execution time Memory
173048 2020-01-03T08:24:26 Z gs13068 Hotter Colder (IOI10_hottercolder) C++17
0 / 100
905 ms 8344 KB
#include "grader.h"
#include <cmath>

int cal(int n) {
  return n < 5 ? 1 : (n + 1 >> 1) - cal(n >> 1);
}

int HC(int N){
  int L = 1, R = N, prv, nxt, t, W = log(3 * N) / log(2);
  while (L < R) {
    if (R == 2) {
      Guess(1);
      return Guess(2) < 0 ? 1 : 2;
    }
    int cut = (2 << W - 2) / 3 + 1;
    nxt = R == N ? cut + cal(R - cut) : cut + cut - 1;
    prv = cut + cut - nxt;
    Guess(prv);
    t = Guess(nxt);
    if (t == -1) R = prv + nxt - 1 >> 1;
    if (t == 0) return prv + nxt >> 1;
    if (t == 1) {
      L = prv + nxt + 2 >> 1;
      prv = nxt;
      while (L < R) {
        nxt = (L + R >> 1 << 1) - prv;
        if (nxt == prv) nxt++;
        if (nxt < 1) nxt = 1;
        if (nxt > N) nxt = N;
        t = Guess(nxt);
        if (t == -1) {
          if (prv < nxt) R = nxt + prv - 1 >> 1;
          else L = nxt + prv + 2 >> 1;
        }
        if (t == 0) return nxt + prv >> 1;
        if (t == 1) {
          if (prv < nxt) L = nxt + prv + 2 >> 1;
          else R = nxt + prv - 1 >> 1;
        }
        prv = nxt;
      }
    }
    W -= 2;
  }
  return L;
}

Compilation message

hottercolder.cpp: In function 'int cal(int)':
hottercolder.cpp:5:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   return n < 5 ? 1 : (n + 1 >> 1) - cal(n >> 1);
                       ~~^~~
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:15:23: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
     int cut = (2 << W - 2) / 3 + 1;
                     ~~^~~
hottercolder.cpp:20:32: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
     if (t == -1) R = prv + nxt - 1 >> 1;
                      ~~~~~~~~~~^~~
hottercolder.cpp:21:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     if (t == 0) return prv + nxt >> 1;
                        ~~~~^~~~~
hottercolder.cpp:23:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       L = prv + nxt + 2 >> 1;
           ~~~~~~~~~~^~~
hottercolder.cpp:26:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         nxt = (L + R >> 1 << 1) - prv;
                ~~^~~
hottercolder.cpp:32:40: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
           if (prv < nxt) R = nxt + prv - 1 >> 1;
                              ~~~~~~~~~~^~~
hottercolder.cpp:33:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
           else L = nxt + prv + 2 >> 1;
                    ~~~~~~~~~~^~~
hottercolder.cpp:35:32: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         if (t == 0) return nxt + prv >> 1;
                            ~~~~^~~~~
hottercolder.cpp:37:40: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
           if (prv < nxt) L = nxt + prv + 2 >> 1;
                              ~~~~~~~~~~^~~
hottercolder.cpp:38:30: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
           else R = nxt + prv - 1 >> 1;
                    ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1400 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1400 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 1396 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 905 ms 8344 KB Output isn't correct - alpha = 0.000000000000