Submission #199164

#TimeUsernameProblemLanguageResultExecution timeMemory
199164dolphingarlicCop and Robber (BOI14_coprobber)C++14
Compilation error
0 ms0 KiB
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "coprobber.h" static unsigned middle_of(bool **A, unsigned N) { // Minimize maximum distance from any intersection. return N / 2; // Assuming the intersections are numbered in order. } static bool **connected; static unsigned intersect_num; static unsigned cop; int start(unsigned N, bool **A) { if (max_cycle_len(A, N) > 3) return -1; const size_t cnct_size = N * N * sizeof(bool); connected = malloc(cnct_size); assert(connected); memcpy(connected, A, cnct_size); intersect_num = N; return cop = middle_of(A, N); } static unsigned intersect_dist(unsigned a, unsigned b, unsigned *visited, unsigned cur_dist) { if (a == b) return 0; visited[cur_dist++] = a; unsigned min; for (unsigned i = 0; i < intersect_num; ++i) { if (connected[a][i] && (!in_arr(visited, i))) } } static void move_cop(unsigned robber, unsigned target_dist) { for (unsigned i = 0; i < intersect_num; ++i) { if (intersect_dist(i, robber) == target_dist) { cop = i; break; } } } unsigned nextMove(unsigned R) { const unsigned d = cop_robber_dist(R); if (d) move_cop(R, d - 1); if (d < 2 && connected) { free(connected); connected = NULL; } return cop; }

Compilation message (stderr)

coprobber.cpp: In function 'int start(unsigned int, bool**)':
coprobber.cpp:19:7: error: 'max_cycle_len' was not declared in this scope
   if (max_cycle_len(A, N) > 3) return -1;
       ^~~~~~~~~~~~~
coprobber.cpp:22:21: error: invalid conversion from 'void*' to 'bool**' [-fpermissive]
   connected = malloc(cnct_size);
               ~~~~~~^~~~~~~~~~~
coprobber.cpp: In function 'unsigned int intersect_dist(unsigned int, unsigned int, unsigned int*, unsigned int)':
coprobber.cpp:37:30: error: 'in_arr' was not declared in this scope
     if (connected[a][i] && (!in_arr(visited, i))) 
                              ^~~~~~
coprobber.cpp:38:3: error: expected primary-expression before '}' token
   }
   ^
coprobber.cpp:35:12: warning: unused variable 'min' [-Wunused-variable]
   unsigned min;
            ^~~
coprobber.cpp: In function 'void move_cop(unsigned int, unsigned int)':
coprobber.cpp:50:33: error: too few arguments to function 'unsigned int intersect_dist(unsigned int, unsigned int, unsigned int*, unsigned int)'
     if (intersect_dist(i, robber) == target_dist) {
                                 ^
coprobber.cpp:31:17: note: declared here
 static unsigned intersect_dist(unsigned a, unsigned b, unsigned *visited, unsigned cur_dist)
                 ^~~~~~~~~~~~~~
coprobber.cpp: In function 'unsigned int nextMove(unsigned int)':
coprobber.cpp:59:22: error: 'cop_robber_dist' was not declared in this scope
   const unsigned d = cop_robber_dist(R);
                      ^~~~~~~~~~~~~~~
coprobber.cpp: At global scope:
coprobber.cpp:47:13: warning: 'void move_cop(unsigned int, unsigned int)' defined but not used [-Wunused-function]
 static void move_cop(unsigned robber, unsigned target_dist)
             ^~~~~~~~