Submission #433989

# Submission time Handle Problem Language Result Execution time Memory
433989 2021-06-20T13:25:24 Z KoD Hotter Colder (IOI10_hottercolder) C++17
Compilation error
0 ms 0 KB
#include <algorithm>
#include "grader.h"

namespace {

char dp[501][501][501];
short select[501][501][501];

char dfs(const int l, const int r, const int x) {
   if (l == r) return 0;
   if (dp[l][r][x] != 0) return dp[l][r][x];
   char min = 100;
   for (int i = l; i < x; ++i) {
      char max = std::max(dfs(std::max(l, (i + x) / 2 + 1), std::min(r, x), i), dfs(std::max(l, i), std::min((i + x - 1) / 2, r), i));
      if (min > max) {
         min = max;
         select[l][r][x] = i;
      }
   }
   for (int i = x + 1; i <= r; ++i) {
      char max = std::max(dfs(std::max(l, (i + x) / 2 + 1), std::min(i, r), i), dfs(std::max(l, x), std::min((i + x - 1) / 2, r), i));
      if (min > max) {
         min = max;
         select[l][r][x] = i;
      }
   }
   return dp[l][r][x] = min + 1;
}

}
  
int HC(int N) {
   int l = 1, r = N, x = 1;
   for (int i = 1; i <= r; ++i) {
      dfs(l, r, i);
      if (dp[l][r][i] < dp[l][r][x]) {
         x = i;
      }
   }
   Guess(x);
   while (l < r) {
      dfs(l, r, x);
      const int k = select[l][r][x];
      const int t = Guess(k);
      if (t == 0) {
         return (x + k) / 2;
      }
      if (t == 1) {
         if (k < x) {
            r = std::min(r, (k + x - 1) / 2);
         } else {
            l = std::max(l, (k + x) / 2 + 1);
         }
      } else {
         if (k < x) {
            l = std::max(l, (k + x) / 2 + 1);
         } else {
            r = std::min(r, (k + x - 1) / 2);
         }
      }
      x = k;
   }
   return l;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:43:21: error: reference to 'select' is ambiguous
   43 |       const int k = select[l][r][x];
      |                     ^~~~~~
hottercolder.cpp:7:7: note: candidates are: 'short int {anonymous}::select [501][501][501]'
    7 | short select[501][501][501];
      |       ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/10/cstdlib:75,
                 from /usr/include/c++/10/bits/stl_algo.h:59,
                 from /usr/include/c++/10/algorithm:62,
                 from hottercolder.cpp:1:
/usr/include/x86_64-linux-gnu/sys/select.h:101:12: note:                 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  101 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~