#include "dungeons.h"
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#define ll long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() {cerr << endl;}
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
int N, lg, cnt;
vector<ll> v;
vector<int> S, P, W, L;
vector<vector<ll>> to[10], Get[10];
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) {
N = n, lg = 35, S = s, P = p, W = w, L = l;
v.push_back(0);
v.push_back(INF);
rep(i, 0, n - 1) v.push_back(S[i]);
sort(all(v)), v.resize(unique(all(v)) - v.begin());
cnt = v.size() - 1;
rep(seg, 0, cnt - 1) {
to[seg].assign(lg + 1, vector<ll>(n + 1, n));
Get[seg].assign(lg + 1, vector<ll>(n + 1, 0));
rep(i, 0, n - 1) {
if(S[i] <= v[seg]) {
to[seg][0][i] = W[i];
Get[seg][0][i] = S[i];
}
else {
to[seg][0][i] = L[i];
Get[seg][0][i] = P[i];
}
}
rep(i, 1, lg) rep(j,0, n) {
to[seg][i][j] = to[seg][i - 1][to[seg][i - 1][j]];
Get[seg][i][j] = Get[seg][i - 1][j] + Get[seg][i - 1][to[seg][i - 1][j]];
}
}
return;
}
pair<int, ll> go(int x, ll z, int id) {
rrep(i, 0, lg) {
if(z + Get[id][i][x] < v[id + 1]) {
z = z + Get[id][i][x];
x = to[id][i][x];
}
}
z = z + Get[id][0][x], x = to[id][0][x];
return {x, z};
}
ll simulate(int x, int z) {
ll cost = z;
rep(i, 0, cnt - 1) {
if(z < v[i + 1] && z >= v[i]) tie(x, cost) = go(x, cost, i);
}
assert(x == N);
return cost;
}
Compilation message
dungeons.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
dungeons.cpp:25:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
25 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
dungeons.cpp:25:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
25 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
11956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2892 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2892 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
2892 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
11956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |