QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137056#6659. 외곽 순환 도로 2blackyuki#Compile Error//C++141.8kb2023-08-09 18:28:052024-07-04 01:27:29

Judging History

你现在查看的是测评时间为 2024-07-04 01:27:29 的历史记录

  • [2024-08-26 15:50:55]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:79ms
  • 内存:46816kb
  • [2024-07-04 01:27:29]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-09 18:28:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<P> vp;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define pb emplace_back
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
const ll inf=1001001001001001001;

long long place_police(vector<int> P, vector<long long> C, vector<long long> W){
    ll n=P.size()+1,K=W.size();
    vi par(n,-1);
    rep(i,n-1)par[i+1]=P[i];
    vvi ch(n);
    REP(i,1,n)ch[par[i]].pb(i);
    vvvvi dp(n,vvvi(2,vvi(2,vi(2,inf))));
    vi ma(n,-1);
    ll id=K-1;
    for(int i=n-1;i>=0;i--){
        if(ch[i].size()==0){
            dp[i][0][0][0]=0;
            dp[i][1][1][1]=0;
            ma[i]=id--;
        }
        else{
            for(ll x:ch[i]){
                rep(j,2)rep(k,2)rep(l,2)chmin(dp[x][j][k][l],dp[x][1-j][k][l]+C[x-1]);
                if(x==ch[i][0])dp[i]=dp[x];
                else{
                    vvvi ndp(2,vvi(2,vi(2,inf)));
                    rep(j,2)rep(k,2)rep(l,2)rep(nk,2)rep(nl,2){
                        ll tmp=dp[i][j][k][l]+dp[x][j][nk][nl];
                        if(l==nk)tmp+=W[ma[i]];
                        chmin(ndp[j][k][nl],tmp);
                    }
                    dp[i]=ndp;
                }
                chmax(ma[i],ma[x]);
            }
            swap(dp[i][0],dp[i][1]);
        }
    }
    ll ans=inf;
    rep(j,2)rep(k,2)rep(l,2)chmin(ans,dp[0][j][k][l]+W[K-1]*(int)(k==l));
    return ans;
}

Details

cc1plus: fatal error: implementer.cpp: No such file or directory
compilation terminated.