제출 #793208

#제출 시각아이디문제언어결과실행 시간메모리
793208pasin30055경찰관과 강도 (BOI14_coprobber)C++14
컴파일 에러
0 ms0 KiB
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <assert.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; } int main(void) { // How the functions are used. unsigned N = getN(); bool **A = getA(); int C = start(N, A); if (C == -1) return 1; unsigned R; do { R = getR(N, A, C); C = next_move(R); } while (C != R); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

coprobber.cpp: In function 'int start(unsigned int, bool**)':
coprobber.cpp:18:7: error: 'max_cycle_len' was not declared in this scope
   18 |   if (max_cycle_len(A, N) > 3) return -1;
      |       ^~~~~~~~~~~~~
coprobber.cpp:21:21: error: invalid conversion from 'void*' to 'bool**' [-fpermissive]
   21 |   connected = malloc(cnct_size);
      |               ~~~~~~^~~~~~~~~~~
      |                     |
      |                     void*
coprobber.cpp: In function 'unsigned int intersect_dist(unsigned int, unsigned int, unsigned int*, unsigned int)':
coprobber.cpp:36:30: error: 'in_arr' was not declared in this scope
   36 |     if (connected[a][i] && (!in_arr(visited, i)))
      |                              ^~~~~~
coprobber.cpp:37:3: error: expected primary-expression before '}' token
   37 |   }
      |   ^
coprobber.cpp:34:12: warning: unused variable 'min' [-Wunused-variable]
   34 |   unsigned min;
      |            ^~~
coprobber.cpp: In function 'void move_cop(unsigned int, unsigned int)':
coprobber.cpp:49:33: error: too few arguments to function 'unsigned int intersect_dist(unsigned int, unsigned int, unsigned int*, unsigned int)'
   49 |     if (intersect_dist(i, robber) == target_dist) {
      |                                 ^
coprobber.cpp:30:17: note: declared here
   30 | static unsigned intersect_dist(unsigned a, unsigned b, unsigned *visited, unsigned cur_dist)
      |                 ^~~~~~~~~~~~~~
coprobber.cpp: In function 'unsigned int nextMove(unsigned int)':
coprobber.cpp:58:22: error: 'cop_robber_dist' was not declared in this scope
   58 |   const unsigned d = cop_robber_dist(R);
      |                      ^~~~~~~~~~~~~~~
coprobber.cpp: In function 'int main()':
coprobber.cpp:71:16: error: 'getN' was not declared in this scope; did you mean 'getw'?
   71 |   unsigned N = getN();
      |                ^~~~
      |                getw
coprobber.cpp:72:14: error: 'getA' was not declared in this scope; did you mean 'getw'?
   72 |   bool **A = getA();
      |              ^~~~
      |              getw
coprobber.cpp:79:9: error: 'getR' was not declared in this scope; did you mean 'getw'?
   79 |     R = getR(N, A, C);
      |         ^~~~
      |         getw
coprobber.cpp:80:9: error: 'next_move' was not declared in this scope; did you mean 'nextMove'?
   80 |     C = next_move(R);
      |         ^~~~~~~~~
      |         nextMove
coprobber.cpp:81:14: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   81 |   } while (C != R);
      |            ~~^~~~