제출 #562999

#제출 시각아이디문제언어결과실행 시간메모리
562999hoanghq2004던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 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 = 5e4 + 10; int n; int nxt[N][24][24]; long long dmin[N][24][24]; long long sum[N][24][24]; 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 < 24; ++i) pivot.push_back(1 << i); 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 if (s[i] >= pivot[b + 1]) { nxt[i][b][0] = l[i]; dmin[i][b][0] = 1e18; sum[i][b][0] = p[i]; } else { nxt[i][b][0] = l[i]; dmin[i][b][0] = w[i]; sum[i][b][0] = p[i]; } } nxt[n][b][0] = n; for (int lg = 1; lg < 24; ++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, long long z) { for (int b = 0; b + 1 < pivot.size(); ++b) { if (i == n) return z; if (z >= pivot[b + 1]) continue; for (int lg = 24; lg >= 0; --lg) { if (nxt[i][b][lg] == n || z + sum[i][b][lg] >= pivot[b + 1] || dmin[i][b][lg] - z <= 0) continue; z += sum[i][b][lg]; i = nxt[i][b][lg]; } z += sum[i][b][0]; i = nxt[i][b][0]; } return z; } //int main() { // 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:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int b = 0; b + 1 < pivot.size(); ++b) {
      |                     ~~~~~~^~~~~~~~~~~~~~
dungeons.cpp: In function 'long long int simulate(int, long long int)':
dungeons.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int b = 0; b + 1 < pivot.size(); ++b) {
      |                     ~~~~~~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccE2fa4d.o: in function `main':
grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status