QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139292 | #1144. Dungeons Game | pandapythoner | 0 | 2431ms | 1625824kb | C++17 | 3.9kb | 2023-08-12 22:05:04 | 2023-08-12 22:05:08 |
Judging History
answer
#ifdef LOCAL
#else
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#endif
#include <bits/stdc++.h>
#include "dungeons.h"
using namespace std;
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const ll inf = 1e9;
mt19937 rnd(234);
const ll bbr = 3;
const ll lgb = 16;
const ll lgn = 16;
const int mxn = 4e5;
int n;
bool s_eq_p;
bool few_dstnct;
vector<ll> s, p;
vector<int> w, l;
vector<array<ll, lgn>> bup, bup_mx, bup_sm;
int d;
vector<ll> dstnct;
vector<ll> layer;
struct dt {
int up;
int mn;
ll sm;
};
auto dbup = new dt[lgb][mxn + 1][lgn];
ll get_layer(ll x) {
ll cnt = 0;
while (x >= bbr) {
cnt += 1;
x /= bbr;
}
return min(cnt, lgb - 1);
}
void init_fuck() {
ll aboba = 1;
for (int lr = 0; lr < lgb; lr += 1) {
for (int i = 0; i <= n; i += 1) {
if (aboba >= s[i]) {
dbup[lr][i][0].up = w[i];
dbup[lr][i][0].sm = s[i];
dbup[lr][i][0].mn = inf;
} else {
dbup[lr][i][0].up = l[i];
dbup[lr][i][0].sm = p[i];
dbup[lr][i][0].mn = s[i];
}
}
for (int j = 1; j < lgn; j += 1) {
for (int i = 0; i <= n; i += 1) {
auto &[u, mn0, sm0] = dbup[lr][i][j - 1];
auto &[v, mn1, sm1] = dbup[lr][u][j - 1];
auto &[t, mn2, sm2] = dbup[lr][v][j - 1];
dbup[lr][i][j].up = t;
dbup[lr][i][j].sm = min((ll)(1e17), sm0 + sm1 + sm2);
dbup[lr][i][j].mn = max(-1ll, min((ll)mn0,
min((ll)mn1 - sm0, (ll)(mn2 - sm1 - sm0))));
}
}
aboba *= bbr;
}
}
void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) {
n = _n;
s.resize(n + 1);
p.resize(n + 1);
w.resize(n + 1);
l.resize(n + 1);
w[n] = l[n] = n;
s[n] = p[n] = 0;
for (int i = 0; i < n; i += 1) {
s[i] = _s[i];
p[i] = _p[i];
w[i] = _w[i];
l[i] = _l[i];
}
init_fuck();
return;
}
ll simulate_fuck(int x, ll z) {
for (int itr = 0; itr < 20 && x != n; itr += 1) {
if (s[x] <= z) {
z += s[x];
x = w[x];
// dz = s[x];
} else {
z += p[x];
x = l[x];
// dz = p[x];
}
}
int lr = 0;
ll lrbbr = 1;
while (x != n) {
while (lrbbr < z) {
lrbbr *= bbr;
lr += 1;
}
if (lr >= lgb) {
z += dbup[lgb - 1][x][lgn - 1].sm;
x = dbup[lgb - 1][x][lgn - 1].up;
} else {
if (dbup[lr][x][0].mn > min(z, inf / 2)) {
for (int j = min((ll)lr, lgn - 1); j >= 0; j -= 1) {
if (dbup[lr][x][j].mn > min(z, inf / 2)) {
z += dbup[lr][x][j].sm;
x = dbup[lr][x][j].up;
if (dbup[lr][x][j].mn > min(z, inf / 2)) {
z += dbup[lr][x][j].sm;
x = dbup[lr][x][j].up;
}
}
}
}
}
if (x == n) {
break;
}
if (s[x] <= z) {
z += s[x];
x = w[x];
// dz = s[x];
} else {
z += p[x];
x = l[x];
// dz = p[x];
}
if (x == n) {
break;
}
// assert(get_layer(dz) >= lr);
}
return z;
}
long long simulate(int x, int z) {
return simulate_fuck(x, z);
}
/*
3 1
2 6 9
3 1 2
2 2 3
1 0 1
2 3
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 11
Accepted
time: 1ms
memory: 34420kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 1 73 9829 6 1 0 0 2 0 7 0 2 0 2 0 6 0 2 0 6 0 2 0 7 0 7 0 10 0 1 0 9 0 5 0 5 0 7 0 5 0 9 0 3 0 8 0 9 0 8 0 6 0 4 0 1 0 9 0 8 0 10 0 10 0 1 0 8 0 8 0 8 0 7 0 3 0 10 0 4 0 2 0 9 0 4 0 1 0 3 0 6 0 10 0 10 0 10 0 1 0 1 0 10 0 1 0 5 0 9 0 2 0 6 0 8 0 9 0 6 0 6 0 6 0 2...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 19659 19658 19659 19659 19663 19659 19663 19659 19658 19658 19661 19658 19660 19662 19662 19658 19662 19660 19660 19659 19660 19659 19663 19661 19658 19660 19659 19661 19661 19658 19659 19659 19659 19658 19660 19661 19661 19659 19660 19661 19658 19660 19663 19...
result:
ok 75 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 34548kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 10 86 1820 5250 4629 1552 6552 3205 7668 2419 6343 9299 8841 5649 9910 9479 9718 2612 7483 2360 7862 1567 8 8 9 5 6 9 8 8 9 10 4 6 4 1 4 6 8 7 4 7 4 7 3 10 4 5 2 10 2 4 0 10 3 4 3 1 0 6 0 4 5 8 9 4 4 5 5 10 7 6 6 5 1 10 8 10 6 1 4 4 9 1 8 7 6 4 5 2 5 3 4 1 5 2 5 ...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 39587 30381 39585 39782 39776 38713 30375 30372 38709 38707 25745 21992 39585 25747 22787 23130 28784 37734 23126 39584 21989 37731 23129 25739 25740 39581 25739 25743 23132 37730 22784 39775 23135 21994 30373 30377 25738 25740 39773 39775 22784 39581 21993 39...
result:
ok 88 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 41120kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 2000 100 6 5 4 7 6 7 8 2 10 8 3 10 1 2 8 6 5 7 6 9 10 9 9 6 5 7 2 9 3 6 1 8 7 2 10 1 1 3 5 7 8 6 2 4 1 4 1 9 6 6 2 8 7 3 8 10 1 7 6 1 3 8 10 5 9 4 9 10 1 1 6 6 7 3 9 5 3 6 10 2 2 6 9 3 10 4 10 7 6 1 6 3 8 9 2 9 6 7 7 10 4 8 10 7 6 7 10 3 4 10 3 1 3 8 7 3 4 2 5 1 ...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 7992 3684 3761 1617 8916 92 736 348 6273 63 113 637 83 648 131 242 42 467 54 76 755 225 6606 406 7559 1112 49 1411 5462 7112 359 3494 586 8880 4130 835 754 4004 120 8010 2458 3495 507 49 26 2624 4822 4229 58 264 657 81 656 119 1867 8231 54 10050 307 251 494 86...
result:
ok 102 lines
Test #4:
score: 0
Accepted
time: 106ms
memory: 240904kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 100 4547 4379 5838 2714 9394 8411 1892 791 1465 7401 5997 8178 5151 4873 7324 3859 4727 8682 5170 2686 3148 7413 5623 5264 2132 6619 1134 5120 2927 826 147 6065 7239 550 2813 5292 4848 6321 3710 9592 5014 5973 6559 6852 3363 198 4823 7881 9224 4018 4851 191...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 52719 67129 59750 66538 53093 63102 57652 28016 46641 62082 85963 65115 73771 61010 61401 65872 54147 47937 73083 66786 35930 57881 64963 64841 74820 21746 68255 59177 98803 71062 53051 62505 64403 47017 28540 54245 66274 53455 64550 53855 67980 44220 49543 52...
result:
ok 102 lines
Test #5:
score: -11
Wrong Answer
time: 10ms
memory: 45204kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 2000 100 8141 764 1797 8119 6328 4665 7687 420 8174 8815 4641 1421 7313 1855 3498 3491 1084 3302 3333 4285 8567 1244 2907 1378 8001 2801 6755 2493 8405 8961 8523 120 808 5134 4477 7844 4806 9466 8461 9148 8234 9132 1848 4376 6836 7735 8708 4661 9938 3736 1348 251...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 53172 53092 57130 26938 53177 53185 53194 53129 53167 53158 57130 53192 56508 53191 57129 53108 59295 42277 53322 53131 53124 26577 53143 34492 57130 56508 53196 53182 53144 53055 53297 53113 53389 56508 53122 53164 53176 53172 38973 31386 53187 53187 53141 53...
result:
wrong answer 3rd lines differ - expected: '59385', found: '53172'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 26
Accepted
time: 1ms
memory: 40876kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 1000 1000 1130998 3946545 6545866 7293696 9624001 5934576 91883 8467808 5293516 4377969 4270305 6396962 273361 88842 3015089 8325041 3690612 3735050 9510254 8527761 1038723 5522813 1877104 5699491 3708597 4192999 6479390 5728351 459885 627590 778790 9813273 44970...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 58554923 59397831 43907143 30396423 65329773 72733211 63602617 61768587 62204954 56621402 17618012 34979569 81400240 40358892 34992290 14843953 33603468 41098136 50889729 38925800 41083189 15432148 39749093 31453558 23471995 55658052 9381381 47354455 58490304 ...
result:
ok 1002 lines
Test #8:
score: -26
Wrong Answer
time: 2431ms
memory: 1625824kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 400000 50000 3 10 1 9 5 8 10 7 3 8 2 7 5 6 3 8 1 5 8 7 2 10 3 2 6 2 10 6 9 2 9 5 10 6 10 7 9 10 5 8 6 7 9 10 6 10 7 7 3 1 2 3 3 1 3 3 4 10 7 4 6 7 5 3 7 9 1 10 9 5 8 4 5 4 1 10 3 4 9 6 6 2 1 4 9 7 7 2 10 2 7 2 3 1 4 3 3 10 1 7 4 6 6 9 4 4 10 9 4 3 9 4 3 7 6 4 3 9...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 26183086 25173101 24639932 17323005 23911681 21313155 28133630 21922345 19197043 26096603 20812039 20599547 27834568 20168071 25638932 26365158 24609835 27271704 17295497 18590930 18275331 27040858 20214190 24642012 16708204 18887169 27669745 26064767 26504701...
result:
wrong answer 6th lines differ - expected: '29354227', found: '17323005'
Subtask #3:
score: 0
Wrong Answer
Test #14:
score: 13
Accepted
time: 1ms
memory: 34740kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 1000 1000 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 2918477 29184...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 17881661 33040130 34604564 25280961 28194570 23906798 15912230 29857216 28036550 24990418 20254260 16847281 36206803 19938498 34824909 24557488 26348424 25668821 22620286 24448869 27422275 16663870 17422116 22692168 15018428 21363378 17674438 14701572 21427171...
result:
ok 1002 lines
Test #15:
score: 0
Accepted
time: 144ms
memory: 242176kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 50000 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 2671299 267...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 57444627 30638506 31612306 25428389 41281602 32571734 33830016 43854914 49556558 19628592 42889496 39731682 17955565 47360652 36351342 38170417 28981343 44668365 45347762 29769758 24486732 25948887 33222555 33033192 42479566 29471696 30285781 25081732 20379694...
result:
ok 50002 lines
Test #16:
score: 0
Accepted
time: 139ms
memory: 238168kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 50000 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 4822500 482...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 91237758344 56798718481 58213038426 2952775546 75786438438 54505200466 150662848548 151777097031 157996669813 120440559935 155551706384 14231353298 139359032883 32245823847 153614854743 114524877618 144226128602 149382227142 86243233153 80444136066 10304964777...
result:
ok 50002 lines
Test #17:
score: 0
Accepted
time: 137ms
memory: 236608kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 50000 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 7377028 9096325 6823007 9168333 985322 1430782 6281615 8519413 8329812 7559422 3246957 9264194 1980097 1854450 6271420 3705626 1726988 4284770 7788992 6152689 8340960 3961611 2243094 4219222 1551774 10052608 4418715 4369412 3434255 6431717 1166384 6716706 1799...
result:
ok 50002 lines
Test #18:
score: 0
Accepted
time: 134ms
memory: 241572kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 50000 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 215566 662504 7967757 8373823 9147232 7391856 2563993 3063168 5940967 2693116 7152186 2919161 1414814 9043090 9003486 1447769 8936836 7049390 3253220 8275423 5626855 8965543 396841 8900139 223406 9266444 499479 3713378 2642994 9277999 6032800 3922678 10011177 ...
result:
ok 50002 lines
Test #19:
score: -13
Wrong Answer
time: 158ms
memory: 237192kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 50000 50000 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 3574781 357...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 44507393 42897398 46472175 17873925 42897387 46472157 51467701 42897398 50046943 46472219 60771289 50046942 53621719 28598288 42897446 42897456 42897427 50046969 65640025 60771287 39322625 46472174 35747842 42897410 28598276 42897417 42897378 39322613 42897412...
result:
wrong answer 34th lines differ - expected: '60771314', found: '45990594'
Subtask #4:
score: 0
Wrong Answer
Test #27:
score: 0
Wrong Answer
time: 4ms
memory: 36788kb
input:
b50747e9-747c-4fca-b3b0-62317b32d2f6 1000 1000 661 832 661 985 832 661 661 985 985 985 661 661 661 985 832 985 661 832 661 832 985 832 985 661 985 661 661 661 661 661 661 985 985 985 661 832 985 661 661 832 985 661 985 832 661 661 832 832 661 661 661 832 661 661 661 985 832 832 832 985 661 661 985 8...
output:
f39eb8f7-7d10-4b4a-af02-d7aef3d4dd0a OK 21024092 23787159 23041267 21350537 27120767 21292871 25822152 25512517 24195955 23172162 25636073 20984614 20875838 21163683 24384761 23377191 22223954 24378654 21075265 25399682 25364687 19645895 19114648 19277804 24098134 20586433 21081797 24061308 20465404...
result:
wrong answer 78th lines differ - expected: '27661787', found: '18722818'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%