제출 #347536

#제출 시각아이디문제언어결과실행 시간메모리
347536happypotato코알라 (APIO17_koala)C++17
컴파일 에러
0 ms0 KiB
#include "koala.h" #include <bits/stdc++.h> int minValue(int N, int W) { // TODO: Implement Subtask 1 solution here. // You may leave this function unmodified if you are not attempting this // subtask. int b[N], r[N]; b[0] = 1; for (int i = 1;i < N;i++) b[i] = 0; playRound(b, r); if (r[0] < 2) return 0; for (int i = 1;i < N;i++) { if (r[i] == 0) return i; } return -1; } int maxValue(int N, int W) { // TODO: Implement Subtask 2 solution here. // You may leave this function unmodified if you are not attempting this // subtask. int b[N], r[N]; vector<int> v; for (int i = 0;i < N;i++) { b[i] = 1; v.push_back(i); } while (!v.empty()) { for (int i = 0;i < N;i++) b[i] = 0; for (int i : v) b[i] = N / v.size(); playRound(b, r); vector<int> v2 = v; v.clear(); for (int i : v2) { if (r[i] > b[i]) { v.push_back(i); } } } return v[0]; } int greaterValue(int N, int W) { // TODO: Implement Subtask 3 solution here. // You may leave this function unmodified if you are not attempting this // subtask. return 0; } void allValues(int N, int W, int *P) { if (W == 2*N) { // TODO: Implement Subtask 4 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } else { // TODO: Implement Subtask 5 solution here. // You may leave this block unmodified if you are not attempting this // subtask. } }

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

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:24:5: error: 'vector' was not declared in this scope
   24 |     vector<int> v;
      |     ^~~~~~
koala.cpp:24:5: note: suggested alternatives:
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from koala.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:386:11: note:   'std::vector'
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from koala.cpp:2:
/usr/include/c++/9/vector:90:13: note:   'std::pmr::vector'
   90 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
koala.cpp:24:12: error: expected primary-expression before 'int'
   24 |     vector<int> v;
      |            ^~~
koala.cpp:27:6: error: 'v' was not declared in this scope
   27 |      v.push_back(i);
      |      ^
koala.cpp:29:13: error: 'v' was not declared in this scope
   29 |     while (!v.empty()) {
      |             ^
koala.cpp:33:13: error: expected primary-expression before 'int'
   33 |      vector<int> v2 = v;
      |             ^~~
koala.cpp:35:19: error: 'v2' was not declared in this scope
   35 |      for (int i : v2) {
      |                   ^~
koala.cpp:41:9: error: 'v' was not declared in this scope
   41 |  return v[0];
      |         ^