Submission #433988

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

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:5:27: error: 'short int select [501][501][501]' redeclared as different kind of entity
    5 | 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: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  101 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
hottercolder.cpp: In function 'char dfs(int, int, int)':
hottercolder.cpp:15:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   15 |          select[l][r][x] = i;
      |                  ^
hottercolder.cpp:15:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   15 |          select[l][r][x] = i;
      |                     ^
hottercolder.cpp:15:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   15 |          select[l][r][x] = i;
      |                        ^
hottercolder.cpp:15:26: error: assignment of read-only location '*(select + ((((sizetype)l) + ((sizetype)r)) + ((sizetype)x)))'
   15 |          select[l][r][x] = i;
      |          ~~~~~~~~~~~~~~~~^~~
hottercolder.cpp:22:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |          select[l][r][x] = i;
      |                  ^
hottercolder.cpp:22:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |          select[l][r][x] = i;
      |                     ^
hottercolder.cpp:22:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |          select[l][r][x] = i;
      |                        ^
hottercolder.cpp:22:26: error: assignment of read-only location '*(select + ((((sizetype)l) + ((sizetype)r)) + ((sizetype)x)))'
   22 |          select[l][r][x] = i;
      |          ~~~~~~~~~~~~~~~~^~~
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:39:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |       const int k = select[l][r][x];
      |                             ^
hottercolder.cpp:39:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |       const int k = select[l][r][x];
      |                                ^
hottercolder.cpp:39:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |       const int k = select[l][r][x];
      |                                   ^
hottercolder.cpp:39:35: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' [-fpermissive]