제출 #569131

#제출 시각아이디문제언어결과실행 시간메모리
569131Ooops_sorry코알라 (APIO17_koala)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #ifndef LOCAL #include "koala.h" #endif // LOCAL #ifdef LOCAL using namespace std; #define pb push_back static int N, W; static int P[105]; static int maxQueries = 3200; static int numQueries; static void runGame(int F); static void grader(); int main() { grader(); return 0; } void playRound(int *B, int *R) { int i, j; int S = 0; for (i=0;i<N;++i) { if ( !(B[i] >= 0 && B[i] <= W) ) { printf("Invalid query.\n"); exit(0); } S += B[i]; } if (S > W) { printf("Invalid query.\n"); exit(0); } numQueries++; if (numQueries > maxQueries) { printf("Too many queries.\n"); exit(0); } int cache[2][205]; int num[2][205]; char taken[105][205]; for (i=0;i<205;++i) { cache[1][i] = 0; num[1][i] = 0; } for (i=0;i<N;++i) { int v = B[i]+1; int ii = i&1; int o = ii^1; for (j=0;j<=W;++j) { cache[ii][j] = cache[o][j]; num[ii][j] = num[o][j]; taken[i][j] = 0; } for (j=W;j>=v;--j) { int h = cache[o][j-v] + P[i]; int hn = num[o][j-v] + 1; if (h > cache[ii][j] || (h == cache[ii][j] && hn > num[ii][j])) { cache[ii][j] = h; num[ii][j] = hn; taken[i][j] = 1; } else { taken[i][j] = 0; } } } int cur = W; for (i=N-1;i>=0;--i) { R[i] = taken[i][cur] ? (B[i] + 1) : 0; cur -= R[i]; } } #endif int minValue(int N, int W) { return 0; } int maxValue(int n, int w) { vector<int> arr(n); iota(arr.begin(), arr.end(), 0); while (arr.size() > 1) { int sz = arr.size(); int can = w / sz; int b[n], r[n]; for (int i = 0; i < n; i++) b[i] = 0; for (auto to : arr) { b[to] = can; } playRound(b, r); vector<int> nw; for (auto to : arr) { if (b[to] == can && r[to] > can) { nw.pb(to); } } swap(arr, nw); } return arr[0]; } int greaterValue(int N, int W) { return 0; } void allValues(int n, int w, int *p) { } #ifdef LOCAL static void runGame(int F) { int i; scanf("%d %d",&N,&W); for (i=0;i<N;++i) { P[i] = i; } random_shuffle(P, P + N); numQueries = 0; if (F == 1) { printf("%d\n", minValue(N, W)); } else if (F == 2) { printf("%d\n", maxValue(N, W)); } else if (F == 3) { printf("%d\n", greaterValue(N, W)); } else if (F == 4) { int userP[105]; allValues(N, W, userP); for (i=0;i<N;i++) { printf("%d ",userP[i]); } printf("\n"); } printf("Made %d calls to playRound.\n", numQueries); } static void grader() { int i; int F, G; scanf("%d %d",&F,&G); for (i=0;i<G;i++) { runGame(F); } } #endif

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

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:94:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   94 |     vector<int> arr(n);
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from koala.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
koala.cpp:94:12: error: expected primary-expression before 'int'
   94 |     vector<int> arr(n);
      |            ^~~
koala.cpp:95:10: error: 'arr' was not declared in this scope
   95 |     iota(arr.begin(), arr.end(), 0);
      |          ^~~
koala.cpp:95:5: error: 'iota' was not declared in this scope; did you mean 'std::iota'?
   95 |     iota(arr.begin(), arr.end(), 0);
      |     ^~~~
      |     std::iota
In file included from /usr/include/c++/10/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/10/bits/stl_numeric.h:88:5: note: 'std::iota' declared here
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~
koala.cpp:105:16: error: expected primary-expression before 'int'
  105 |         vector<int> nw;
      |                ^~~
koala.cpp:108:17: error: 'nw' was not declared in this scope; did you mean 'n'?
  108 |                 nw.pb(to);
      |                 ^~
      |                 n
koala.cpp:111:19: error: 'nw' was not declared in this scope; did you mean 'n'?
  111 |         swap(arr, nw);
      |                   ^~
      |                   n
koala.cpp:111:9: error: 'swap' was not declared in this scope
  111 |         swap(arr, nw);
      |         ^~~~
koala.cpp:111:9: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from koala.cpp:1:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from koala.cpp:1:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from koala.cpp:1:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~