제출 #563224

#제출 시각아이디문제언어결과실행 시간메모리
563224hoanghq2004던전 (IOI21_dungeons)C++17
37 / 100
7075 ms1586976 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "dungeons.h" using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 4e5 + 10; int n; int s[N], p[N], w[N], l[N]; int nxt[N][8][25]; long long dmin[N][8][25]; long long sum[N][8][25]; vector <long long> pivot; void init(int _n, std::vector<int> S, std::vector<int> P, std::vector<int> W, std::vector<int> L) { n = _n; for (int i = 0; i < n; ++i) s[i] = S[i], p[i] = P[i], w[i] = W[i], l[i] = L[i]; for (int i = 0; i < 8; ++i) pivot.push_back(1 << i * 3); pivot.push_back(1e18); for (int b = 0; b + 1 < pivot.size(); ++b) { for (int i = 0; i < n; ++i) { if (s[i] < pivot[b]) { nxt[i][b][0] = w[i]; dmin[i][b][0] = 1e18; sum[i][b][0] = s[i]; } else { nxt[i][b][0] = l[i]; dmin[i][b][0] = s[i]; sum[i][b][0] = p[i]; } } nxt[n][b][0] = n; for (int lg = 1; lg < 25; ++lg) { for (int i = 0; i <= n; ++i) { nxt[i][b][lg] = nxt[nxt[i][b][lg - 1]][b][lg - 1]; sum[i][b][lg] = sum[i][b][lg - 1] + sum[nxt[i][b][lg - 1]][b][lg - 1]; dmin[i][b][lg] = min(dmin[i][b][lg - 1], dmin[nxt[i][b][lg - 1]][b][lg - 1] - sum[i][b][lg - 1]); } } } } long long simulate(int i, int z) { long long cur = z; for (int b = 0; b + 1 < pivot.size(); ++b) { if (i == n) return cur; if (cur >= pivot[b + 1]) continue; while (1) { for (int lg = 24; lg >= 0; --lg) { if (nxt[i][b][lg] == n || cur + sum[i][b][lg] >= pivot[b + 1] || dmin[i][b][lg] - cur <= 0) continue; cur += sum[i][b][lg]; i = nxt[i][b][lg]; } if (cur >= s[i]) { cur += s[i]; i = w[i]; } else { cur += p[i]; i = l[i]; } if (i == n || cur >= pivot[b + 1]) break; } } return cur; } // //int main() { //// freopen("test.inp", "r", stdin); //// freopen("test.out", "w", stdout); // int n, q; // std::vector<int> s, p, z; // std::vector<int> w, l, x; // std::vector<long long> answer; // // assert(scanf("%d %d", &n, &q) == 2); // s.resize(n); // p.resize(n); // w.resize(n); // l.resize(n); // x.resize(q); // z.resize(q); // answer.resize(q); // // for (int i = 0; i < n; i++) { // assert(scanf("%d", &s[i]) == 1); // } // for (int i = 0; i < n; i++) { // assert(scanf("%d", &p[i]) == 1); // } // for (int i = 0; i < n; i++) { // assert(scanf("%d", &w[i]) == 1); // } // for (int i = 0; i < n; i++) { // assert(scanf("%d", &l[i]) == 1); // } // // // init(n, s, p, w, l); // // for (int i = 0; i < q; i++) { // assert(scanf("%d %d", &x[i], &z[i]) == 2); // answer[i] = simulate(x[i], z[i]); // } // fclose(stdin); // // for (int i = 0; i < q; i++) { // printf("%lld\n", answer[i]); // } // fclose(stdout); // return 0; //}

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int b = 0; b + 1 < pivot.size(); ++b) {
      |                     ~~~~~~^~~~~~~~~~~~~~
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int b = 0; b + 1 < pivot.size(); ++b) {
      |                     ~~~~~~^~~~~~~~~~~~~~
#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...