제출 #794492

#제출 시각아이디문제언어결과실행 시간메모리
794492mathematik던전 (IOI21_dungeons)C++17
37 / 100
3265 ms1898728 KiB
#include "dungeons.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll using namespace std; uint binary[12][400001][25][2];//index, +, max excluded ull binary_add[12][400001][25]; uint safe_sub(uint a, uint b) { if (a >= b) return a - b; return 0; } int N; vector<int> S, P, W, L; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { s.push_back(0); p.push_back(0); w.push_back(n); l.push_back(n); n++; N = n; S = s, P = p, W = w, L = l; for (int range = 0; range < 12; range++) { ll r = 1 << (range + 13); for (int i = 0; i < n; i++) { if (s[i] <= r) { binary[range][i][0][0] = w[i]; binary_add[range][i][0] = s[i]; binary[range][i][0][1] = UINT_MAX; } else { binary[range][i][0][0] = l[i]; binary_add[range][i][0] = p[i]; binary[range][i][0][1] = s[i]; } } for (int i = 1; i < 25; i++) { for (int ind = 0; ind < n; ind++) { int pointer = binary[range][ind][i - 1][0]; binary[range][ind][i][0] = binary[range][pointer][i - 1][0]; binary_add[range][ind][i] = binary_add[range][ind][i - 1] + binary_add[range][pointer][i - 1]; binary[range][ind][i][1] = min(binary[range][ind][i - 1][1], safe_sub(binary[range][pointer][i - 1][1], binary_add[range][ind][i - 1])); } } } } long long simulate(int x, int z) { ll t = z; while (t < 8192 && x != N - 1) { if (t >= S[x]) { t += S[x]; x = W[x]; } else { t += P[x]; x = L[x]; } } int c = 0; for (int r = 0; r < 12; r++) { for (int s = 24; s >= 0; s--) { if (binary[r][x][s][1] > t || binary[r][x][s][1] == UINT_MAX) { t += binary_add[r][x][s]; x = binary[r][x][s][0]; } } } return t; }

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

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:73:8: warning: unused variable 'c' [-Wunused-variable]
   73 |    int c = 0;
      |        ^
#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...