제출 #1082384

#제출 시각아이디문제언어결과실행 시간메모리
1082384HappyCapybara던전 (IOI21_dungeons)C++17
25 / 100
668 ms222236 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; #define ll long long int st; int n; vector<int> s, p, w, l, ds; vector<vector<vector<pair<int,ll>>>> v; vector<vector<vector<ll>>> u; void init(int N, vector<int> S, vector<int> P, vector<int> W, vector<int> L){ n = N; s = S; p = P; w = W; l = L; for (int i=0; i<n; i++){ int b = true; for (int x : ds){ if (x == s[i]) b = false; } if (b) ds.push_back(s[i]); } if (ds.size() > 5) st = 0; else st = 1; if (st == 0){ u.resize(n+1, vector<vector<ll>>(30)); for (int i=0; i<30; i++){ for (int j=0; j<=n; j++){ if (i == 0) u[j][i] = {w[j], s[j], s[j]}; else { u[j][i].push_back(u[u[j][i-1][0]][i-1][0]); u[j][i].push_back(u[j][i-1][1] + u[u[j][i-1][0]][i-1][1]); u[j][i].push_back(max(u[j][i-1][2], u[u[j][i-1][0]][i-1][2]-u[j][i-1][1])); } } } return; } ds.push_back(0); sort(ds.begin(), ds.end()); s.push_back(0); p.push_back(0); w.push_back(n); l.push_back(n); v.resize(ds.size(), vector<vector<pair<int,ll>>>(n+1, vector<pair<int,ll>>(30))); for (int k=0; k<ds.size(); k++){ for (int i=0; i<30; i++){ for (int j=0; j<=n; j++){ if (i == 0){ if (ds[k] < s[j] ) v[k][j][i] = {l[j], p[j]}; else v[k][j][i] = {w[j], s[j]}; } else { v[k][j][i].first = v[k][v[k][j][i-1].first][i-1].first; v[k][j][i].second = v[k][j][i-1].second + v[k][v[k][j][i-1].first][i-1].second; } } } } /*for (int k=0; k<1; k++){ for (int i=0; i<n; i++){ for (int j=0; j<5; j++){ cout << v[k][i][j].first << " " << v[k][i][j].second << "\n"; } cout << "\n"; } }*/ return; } ll simulate(int x, int z){ if (st == 0){ ll y = z; while (x != n){ int i = 0; while (u[x][i][2] <= y){ i++; if (u[x][i-1][0] == n) break; } if (i == 0){ y += p[x]; x = l[x]; } else { y += u[x][i-1][1]; x = u[x][i-1][0]; } } return y; } ll y = z; int cur = 0; while (cur < ds.size()){ while ((cur == ds.size()-1 || y < ds[cur+1]) && x != n){ int i = 0; while ((cur == ds.size()-1 || y+v[cur][x][i+1].second < ds[cur+1]) && v[cur][x][i].first != n) i++; y += v[cur][x][i].second; x = v[cur][x][i].first; } cur++; } return y; }

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int k=0; k<ds.size(); k++){
      |                   ~^~~~~~~~~~
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:102:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |     while (cur < ds.size()){
      |            ~~~~^~~~~~~~~~~
dungeons.cpp:103:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |      while ((cur == ds.size()-1 || y < ds[cur+1]) && x != n){
      |              ~~~~^~~~~~~~~~~~~~
dungeons.cpp:105:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |       while ((cur == ds.size()-1 || y+v[cur][x][i+1].second < ds[cur+1]) && v[cur][x][i].first != n) i++;
      |               ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...