답안 #990940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990940 2024-05-31T20:41:26 Z AdamGS 던전 (IOI21_dungeons) C++17
89 / 100
7000 ms 1876668 KB
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=4e5+7, LG=24, LG2=15, INF=1e9+7;
int nxt[LIM][LG][LG2], sum[LIM][LG][LG2], ile[LIM][LG][LG2];
ll nxt2[LIM][LG], sum2[LIM][LG], S[LIM], P[LIM], W[LIM], L[LIM], n;
void init(int _n, vector<int>_s, vector<int>_p, vector<int>_w, vector<int>_l) {
  n=_n;
  rep(i, n) {
    S[i]=_s[i];
    P[i]=_p[i];
    W[i]=_w[i];
    L[i]=_l[i];
  }
  rep(i, LG) {
    nxt[n][i][0]=n;
    rep(j, n) {
      if(S[j]>=(1<<i)) {
        nxt[j][i][0]=L[j];
        sum[j][i][0]=P[j];
        ile[j][i][0]=min(S[j], (1<<(i+1))-P[j]);
      } else {
        nxt[j][i][0]=W[j];
        sum[j][i][0]=S[j];
        ile[j][i][0]=(1<<(i+1))-S[j];
      }
    }
    for(int l=1; l<LG2; ++l) {
      rep(j, n+1) {
        nxt[j][i][l]=nxt[nxt[nxt[j][i][l-1]][i][l-1]][i][l-1];
        sum[j][i][l]=sum[j][i][l-1]+sum[nxt[j][i][l-1]][i][l-1]+sum[nxt[nxt[j][i][l-1]][i][l-1]][i][l-1];
        ile[j][i][l]=ile[j][i][l-1];
        ile[j][i][l]=min(ile[j][i][l], ile[nxt[j][i][l-1]][i][l-1]-sum[j][i][l-1]);
        ile[j][i][l]=min(ile[j][i][l], ile[nxt[nxt[j][i][l-1]][i][l-1]][i][l-1]-sum[j][i][l-1]-sum[nxt[j][i][l-1]][i][l-1]);
        sum[j][i][l]=min(sum[j][i][l], INF);
        ile[j][i][l]=max(ile[j][i][l], 0);
      }
    }
  }
  nxt2[n][0]=n;
  rep(i, n) {
    nxt2[i][0]=W[i];
    sum2[i][0]=S[i];
  }
  for(int j=1; j<LG; ++j) {
    rep(i, n+1) {
      nxt2[i][j]=nxt2[nxt2[i][j-1]][j-1];
      sum2[i][j]=sum2[nxt2[i][j-1]][j-1]+sum2[i][j-1];
    }
  }
  return;
}
ll simulate(int x, int _z) {
  ll z=_z;
  rep(i, LG) if(z<(1ll<<(ll)(i+1))) {
    for(int j=LG2-1; j>=0; --j) if(nxt[x][i][j]<n && ile[x][i][j]>z) {
      z+=sum[x][i][j];
      x=nxt[x][i][j];
      if(nxt[x][i][j]<n && ile[x][i][j]>z) {
        z+=sum[x][i][j];
        x=nxt[x][i][j];
      }
    }
    if(z>=S[x]) {
      z+=S[x];
      x=W[x];
    } else {
      z+=P[x];
      x=L[x];
    }
    if(x==n) return z;
  }
  for(int i=LG-1; i>=0; --i) if(nxt2[x][i]<n) {
    z+=sum2[x][i];
    x=nxt2[x][i];
  }
  z+=sum2[x][0];
  x=nxt2[x][0];
  return z;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 16732 KB Output is correct
2 Correct 2 ms 16732 KB Output is correct
3 Correct 9 ms 25180 KB Output is correct
4 Correct 221 ms 253248 KB Output is correct
5 Correct 9 ms 25180 KB Output is correct
6 Correct 219 ms 253240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20824 KB Output is correct
2 Correct 4606 ms 1871480 KB Output is correct
3 Correct 4251 ms 1871476 KB Output is correct
4 Correct 4046 ms 1871956 KB Output is correct
5 Correct 3368 ms 1871996 KB Output is correct
6 Correct 5342 ms 1871188 KB Output is correct
7 Correct 4855 ms 1870416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20824 KB Output is correct
2 Correct 247 ms 254540 KB Output is correct
3 Correct 231 ms 254564 KB Output is correct
4 Correct 251 ms 254136 KB Output is correct
5 Correct 270 ms 254288 KB Output is correct
6 Correct 291 ms 254280 KB Output is correct
7 Correct 277 ms 254292 KB Output is correct
8 Correct 395 ms 254264 KB Output is correct
9 Correct 215 ms 254240 KB Output is correct
10 Correct 381 ms 254032 KB Output is correct
11 Correct 355 ms 254284 KB Output is correct
12 Correct 1235 ms 254276 KB Output is correct
13 Correct 1210 ms 254288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20824 KB Output is correct
2 Correct 247 ms 254540 KB Output is correct
3 Correct 231 ms 254564 KB Output is correct
4 Correct 251 ms 254136 KB Output is correct
5 Correct 270 ms 254288 KB Output is correct
6 Correct 291 ms 254280 KB Output is correct
7 Correct 277 ms 254292 KB Output is correct
8 Correct 395 ms 254264 KB Output is correct
9 Correct 215 ms 254240 KB Output is correct
10 Correct 381 ms 254032 KB Output is correct
11 Correct 355 ms 254284 KB Output is correct
12 Correct 1235 ms 254276 KB Output is correct
13 Correct 1210 ms 254288 KB Output is correct
14 Correct 5 ms 20828 KB Output is correct
15 Correct 209 ms 254540 KB Output is correct
16 Correct 224 ms 254540 KB Output is correct
17 Correct 240 ms 254280 KB Output is correct
18 Correct 243 ms 254280 KB Output is correct
19 Correct 252 ms 254280 KB Output is correct
20 Correct 337 ms 254032 KB Output is correct
21 Correct 396 ms 254220 KB Output is correct
22 Correct 408 ms 254280 KB Output is correct
23 Correct 591 ms 254284 KB Output is correct
24 Correct 780 ms 254292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20824 KB Output is correct
2 Correct 247 ms 254540 KB Output is correct
3 Correct 231 ms 254564 KB Output is correct
4 Correct 251 ms 254136 KB Output is correct
5 Correct 270 ms 254288 KB Output is correct
6 Correct 291 ms 254280 KB Output is correct
7 Correct 277 ms 254292 KB Output is correct
8 Correct 395 ms 254264 KB Output is correct
9 Correct 215 ms 254240 KB Output is correct
10 Correct 381 ms 254032 KB Output is correct
11 Correct 355 ms 254284 KB Output is correct
12 Correct 1235 ms 254276 KB Output is correct
13 Correct 1210 ms 254288 KB Output is correct
14 Correct 5 ms 20828 KB Output is correct
15 Correct 209 ms 254540 KB Output is correct
16 Correct 224 ms 254540 KB Output is correct
17 Correct 240 ms 254280 KB Output is correct
18 Correct 243 ms 254280 KB Output is correct
19 Correct 252 ms 254280 KB Output is correct
20 Correct 337 ms 254032 KB Output is correct
21 Correct 396 ms 254220 KB Output is correct
22 Correct 408 ms 254280 KB Output is correct
23 Correct 591 ms 254284 KB Output is correct
24 Correct 780 ms 254292 KB Output is correct
25 Correct 219 ms 253500 KB Output is correct
26 Correct 234 ms 254544 KB Output is correct
27 Correct 224 ms 254052 KB Output is correct
28 Correct 216 ms 254196 KB Output is correct
29 Correct 243 ms 254544 KB Output is correct
30 Correct 434 ms 254292 KB Output is correct
31 Correct 488 ms 254036 KB Output is correct
32 Correct 482 ms 254292 KB Output is correct
33 Correct 296 ms 254292 KB Output is correct
34 Correct 379 ms 254288 KB Output is correct
35 Correct 342 ms 254288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20824 KB Output is correct
2 Correct 4606 ms 1871480 KB Output is correct
3 Correct 4251 ms 1871476 KB Output is correct
4 Correct 4046 ms 1871956 KB Output is correct
5 Correct 3368 ms 1871996 KB Output is correct
6 Correct 5342 ms 1871188 KB Output is correct
7 Correct 4855 ms 1870416 KB Output is correct
8 Correct 5 ms 20824 KB Output is correct
9 Correct 247 ms 254540 KB Output is correct
10 Correct 231 ms 254564 KB Output is correct
11 Correct 251 ms 254136 KB Output is correct
12 Correct 270 ms 254288 KB Output is correct
13 Correct 291 ms 254280 KB Output is correct
14 Correct 277 ms 254292 KB Output is correct
15 Correct 395 ms 254264 KB Output is correct
16 Correct 215 ms 254240 KB Output is correct
17 Correct 381 ms 254032 KB Output is correct
18 Correct 355 ms 254284 KB Output is correct
19 Correct 1235 ms 254276 KB Output is correct
20 Correct 1210 ms 254288 KB Output is correct
21 Correct 5 ms 20828 KB Output is correct
22 Correct 209 ms 254540 KB Output is correct
23 Correct 224 ms 254540 KB Output is correct
24 Correct 240 ms 254280 KB Output is correct
25 Correct 243 ms 254280 KB Output is correct
26 Correct 252 ms 254280 KB Output is correct
27 Correct 337 ms 254032 KB Output is correct
28 Correct 396 ms 254220 KB Output is correct
29 Correct 408 ms 254280 KB Output is correct
30 Correct 591 ms 254284 KB Output is correct
31 Correct 780 ms 254292 KB Output is correct
32 Correct 219 ms 253500 KB Output is correct
33 Correct 234 ms 254544 KB Output is correct
34 Correct 224 ms 254052 KB Output is correct
35 Correct 216 ms 254196 KB Output is correct
36 Correct 243 ms 254544 KB Output is correct
37 Correct 434 ms 254292 KB Output is correct
38 Correct 488 ms 254036 KB Output is correct
39 Correct 482 ms 254292 KB Output is correct
40 Correct 296 ms 254292 KB Output is correct
41 Correct 379 ms 254288 KB Output is correct
42 Correct 342 ms 254288 KB Output is correct
43 Correct 2 ms 16732 KB Output is correct
44 Correct 5 ms 20828 KB Output is correct
45 Correct 4867 ms 1873816 KB Output is correct
46 Correct 3433 ms 1871280 KB Output is correct
47 Correct 3671 ms 1871272 KB Output is correct
48 Correct 3197 ms 1872956 KB Output is correct
49 Correct 4573 ms 1874516 KB Output is correct
50 Correct 4536 ms 1871332 KB Output is correct
51 Correct 3021 ms 1876668 KB Output is correct
52 Correct 4679 ms 1874516 KB Output is correct
53 Execution timed out 7121 ms 1727808 KB Time limit exceeded
54 Halted 0 ms 0 KB -