제출 #1011098

#제출 시각아이디문제언어결과실행 시간메모리
10110981ne던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include "dungeons.h" #include <vector> #include <bits/stdc++.h> const int k = 20; vector<vector<int>>table; vector<vector<int>>nx; vector<vector<int>>sum; vector<int>S,P,W,L; int N; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { table.resize(n,vector<int>(k)); nx.resize(n,vector<int>(k,-1)); sum.resize(n,vector<int>(k,0)); N = n; S = s; P = p; W = w; L = l; for (int i = 0;i<n;++i){ table[i][0] = s[i]; nx[i][0] = w[i]; sum[i][0] = s[i]; } for (int i = 1;i<k;++i){ for (int j = 0;j<n;++j){ if (nx[j][i - 1] == -1)continue; nx[j][i] = nx[nx[j][i - 1]][i - 1]; table[j][i] = max(table[j][i - 1],table[nx[j][i - 1]][i - 1] - sum[j][i - 1]); sum[j][i] = sum[j][i - 1] + sum[nx[j][i - 1]][i - 1]; } } return; } long long simulate(int x, int z) { long long Z = z; while(x != N){ int c = 0; while(nx[x][c] != -1 && table[x][c] <= z){ ++c; } if (c != 0){ Z+=sum[x][c - 1]; x = nx[x][c - 1]; } if (x != N){ Z+=P[x]; x = L[x]; } } return Z; }

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

dungeons.cpp:5:1: error: 'vector' does not name a type
    5 | vector<vector<int>>table;
      | ^~~~~~
dungeons.cpp:6:1: error: 'vector' does not name a type
    6 | vector<vector<int>>nx;
      | ^~~~~~
dungeons.cpp:7:1: error: 'vector' does not name a type
    7 | vector<vector<int>>sum;
      | ^~~~~~
dungeons.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int>S,P,W,L;
      | ^~~~~~
dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:11:2: error: 'table' was not declared in this scope
   11 |  table.resize(n,vector<int>(k));
      |  ^~~~~
dungeons.cpp:11:17: error: 'vector' was not declared in this scope
   11 |  table.resize(n,vector<int>(k));
      |                 ^~~~~~
dungeons.cpp:11:17: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dungeons.cpp:11:24: error: expected primary-expression before 'int'
   11 |  table.resize(n,vector<int>(k));
      |                        ^~~
dungeons.cpp:12:2: error: 'nx' was not declared in this scope; did you mean 'n'?
   12 |  nx.resize(n,vector<int>(k,-1));
      |  ^~
      |  n
dungeons.cpp:12:21: error: expected primary-expression before 'int'
   12 |  nx.resize(n,vector<int>(k,-1));
      |                     ^~~
dungeons.cpp:13:2: error: 'sum' was not declared in this scope
   13 |  sum.resize(n,vector<int>(k,0));
      |  ^~~
dungeons.cpp:13:22: error: expected primary-expression before 'int'
   13 |  sum.resize(n,vector<int>(k,0));
      |                      ^~~
dungeons.cpp:15:2: error: 'S' was not declared in this scope
   15 |  S = s;
      |  ^
dungeons.cpp:16:2: error: 'P' was not declared in this scope
   16 |  P = p;
      |  ^
dungeons.cpp:17:2: error: 'W' was not declared in this scope
   17 |  W = w;
      |  ^
dungeons.cpp:18:2: error: 'L' was not declared in this scope
   18 |  L = l;
      |  ^
dungeons.cpp:29:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   29 |    table[j][i] = max(table[j][i - 1],table[nx[j][i - 1]][i - 1] - sum[j][i - 1]);
      |                  ^~~
      |                  std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dungeons.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:40:9: error: 'nx' was not declared in this scope; did you mean 'x'?
   40 |   while(nx[x][c] != -1 && table[x][c] <= z){
      |         ^~
      |         x
dungeons.cpp:40:27: error: 'table' was not declared in this scope
   40 |   while(nx[x][c] != -1 && table[x][c] <= z){
      |                           ^~~~~
dungeons.cpp:44:7: error: 'sum' was not declared in this scope
   44 |    Z+=sum[x][c - 1];
      |       ^~~
dungeons.cpp:45:8: error: 'nx' was not declared in this scope; did you mean 'x'?
   45 |    x = nx[x][c - 1];
      |        ^~
      |        x
dungeons.cpp:48:7: error: 'P' was not declared in this scope
   48 |    Z+=P[x];
      |       ^
dungeons.cpp:49:8: error: 'L' was not declared in this scope
   49 |    x = L[x];
      |        ^