제출 #600257

#제출 시각아이디문제언어결과실행 시간메모리
600257PiejanVDC던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "dungeons.h" using namespace std; const int mxN = (int)5e4+5; const int lg = (int)32; long long lim[mxN][lg][32]; long long gget[mxN][lg][32]; int jump[mxN][lg][32]; int N; vector<int>S; vector<int>P; vector<int>W; vector<int>L; bool _ = 1; void init(int n, vector<int>s, vector<int>p, vector<int>w, vector<int>l) { for(int i = 0 ; i < n ; i++) if(s[i] != p[i]) _ = 0; if(_) { L = l; S = s; N = n; for(int i = 0 ; i < n ; i++) { jump[i][0] = w[i]; lim[i][0] = s[i]; gget[i][0] = s[i]; } jump[n][0] = n; for(int j = 1 ; j <= 30 ; j++) { for(int i = 0 ; i <= n ; i++) { jump[i][j] = jump[jump[i][j-1]][j-1]; lim[i][j] = max(lim[i][j-1], lim[jump[i][j-1]][j-1] - gget[i][j-1]); gget[i][j] = gget[i][j-1] + gget[jump[i][j-1]][j-1]; } } return; } S = s, P = p, W = w, L = l; N = n; for(int j = 0 ; j < lg ; j++) { for(int i = 0 ; i < n ; i++) { if(pow(2,j) >= s[i]) { lim[i][j][0] = LLONG_MAX; gget[i][j][0] = s[i]; jump[i][j][0] = w[i]; } else { lim[i][j][0] = s[i]; gget[i][j][0] = p[i]; jump[i][j][0] = l[i]; } } } for(int k = 1 ; k < 30 ; k++) { for(int j = 0 ; j < lg ; j++) { for(int i = 0 ; i < n ; i++) { lim[i][j][k] = (lim[i][j][k-1] == LLONG_MAX && lim[ jump[i][j][k-1] ][j][k-1] - gget[i][j][k-1] == LLONG_MAX ? LLONG_MAX : min(lim[i][j][k-1], lim[ jump[i][j][k-1] ][j][k-1] - gget[i][j][k-1])); gget[i][j][k] = gget[i][j][k-1] + gget[ jump[i][j][k-1] ][j][k-1]; jump[i][j][k] = jump[ jump[i][j][k-1] ][j][k-1]; } } } } long long simulate(int x, int z) { if(_) { long long ans = z; while(x != N) { for(int j = 30 ; j >= 0 ; j--) { if(jump[x][j] != N && ans >= lim[x][j]) { ans += gget[x][j]; x = jump[x][j]; } } if(x != N) { if(lim[x][0] <= ans) { ans += S[x]; x = jump[x][0]; } else { ans += S[x]; x = L[x]; } } } return ans; } long long c = z; int pw = 0; while(x != N) { while(pow(2,(pw+1)) <= c && pw+1 <= 30) { pw++; } for(int j = 30 ; j >= 0 ; j--) { if(lim[x][pw][j] > c && jump[x][pw][j] != N) { c += gget[x][pw][j]; x = jump[x][pw][j]; } } if(x != N) { if(c >= S[x]) { c += S[x]; x = W[x]; } else { c += P[x]; x = L[x]; } } } return c; }

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:29:20: error: incompatible types in assignment of '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'int [32]'
   29 |         jump[i][0] = w[i];
dungeons.cpp:30:19: error: incompatible types in assignment of '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'long long int [32]'
   30 |         lim[i][0] = s[i];
dungeons.cpp:31:20: error: incompatible types in assignment of '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'long long int [32]'
   31 |         gget[i][0] = s[i];
dungeons.cpp:33:16: error: incompatible types in assignment of 'int' to 'int [32]'
   33 |     jump[n][0] = n;
      |     ~~~~~~~~~~~^~~
dungeons.cpp:36:30: error: invalid types 'int [50005][32][32][int [32]]' for array subscript
   36 |             jump[i][j] = jump[jump[i][j-1]][j-1];
      |                              ^
dungeons.cpp:37:45: error: invalid types 'long long int [50005][32][32][int [32]]' for array subscript
   37 |             lim[i][j] = max(lim[i][j-1], lim[jump[i][j-1]][j-1] - gget[i][j-1]);
      |                                             ^
dungeons.cpp:38:45: error: invalid types 'long long int [50005][32][32][int [32]]' for array subscript
   38 |             gget[i][j] = gget[i][j-1] + gget[jump[i][j-1]][j-1];
      |                                             ^
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:80:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   80 |             if(jump[x][j] != N && ans >= lim[x][j]) {
      |                ~~~~~~~~~~~^~~~
dungeons.cpp:80:39: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   80 |             if(jump[x][j] != N && ans >= lim[x][j]) {
      |                                   ~~~~^~~~~~~~~~~~
dungeons.cpp:81:21: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive]
   81 |                 ans += gget[x][j];
      |                 ~~~~^~~~~~~~~~~~~
      |                     |
      |                     long long int*
dungeons.cpp:82:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   82 |                 x = jump[x][j];
      |                     ~~~~~~~~~^
      |                              |
      |                              int*
dungeons.cpp:86:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   86 |             if(lim[x][0] <= ans) {
      |                ~~~~~~~~~~^~~~~~
dungeons.cpp:88:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   88 |                 x = jump[x][0];
      |                     ~~~~~~~~~^
      |                              |
      |                              int*