QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140088#1144. Dungeons GamechenjbCompile Error//C++141.5kb2023-08-15 05:01:172023-08-15 05:01:18

Judging History

你现在查看的是最新测评结果

  • [2023-08-15 05:01:18]
  • 评测
  • [2023-08-15 05:01:17]
  • 提交

answer

#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#include "dungeons.h"
typedef long long ll;
const int N=50005;
struct Node{
    int person;
    ll op,gained;
}dp[N][24][24];
int _n;
Node Merge(Node a,Node b){
    Node res;
    res.person=b.person;
    res.gained=a.gained+b.gained;
    res.op=max({1LL*a.op,b.op+a.gained});
    return res;
}
vector<int>_s,_p,_w,_l;
void init(int n,vector<int>s,vector<int>p,vector<int>w,vector<int>l){
    _n=n;
    _s=s,_p=p,_w=w,_l=l;
    for(int i=0;i<n;i++){
        for(int j=0;j<24;j++){
            for(int k=0;k<24;k++){
                if(s[i]>=(1<<k))dp[i][j][k]={l[i],-s[i],p[i]};
                else dp[i][j][k]={w[i],LLONG_MIN,s[i]};
            }
        }
    }
    for(int j=0;j<24;j++){
        for(int k=0;k<24;k++){
            dp[n][j][k]={n,0,0};
        }
    }
    for(int j=1;j<24;j++)for(int i=0;i<n;i++){
        for(int k=0;k<24;k++){
            dp[i][j][k]=Merge(dp[i][j-1][k],dp[dp[i][j-1][k].person][j-1][k]);
        }
    }
	return;
}

long long simulate(int x,ll z){
    while(x!=_n){
        int k=__lg(z);
        if(z>=_s[x]&&_s[x]>=(1LL<<k)){
            z+=_s[x];
            x=_w[x];
            continue;
        }
        for(int j=23;j>=0;j--){
            if(z+dp[x][j][k].op<0){
                z+=dp[x][j][k].gained;
                x=dp[x][j][k].person;
            }
        }
        if(z>=_s[x]&&_s[x]>=(1LL<<k)){
            z+=_s[x];
            x=_w[x];
        }
    }
    return z;
}

Details

/usr/bin/ld: /tmp/ccUg7gzJ.o: in function `main':
implementer.cpp:(.text.startup+0x423): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status