QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116261#6659. 외곽 순환 도로 2Irisu#Compile Error//C++171.8kb2023-06-28 12:46:542024-05-31 18:26:08

Judging History

你现在查看的是测评时间为 2024-05-31 18:26:08 的历史记录

  • [2024-08-26 15:50:04]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:40ms
  • 内存:32812kb
  • [2024-05-31 18:26:08]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-28 12:46:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(y<x)x=y;}

#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define mem(x) memset((x),0,sizeof(x))

typedef double db;
typedef long long ll;
typedef vector<int>vi;
typedef pair<int,int>pii;

int n;

vector<vi>E;
vector<ll>C,W;

int cur;
ll rig[100010];
ll dp[100010][2][2][2];

void dfs(int u){
  bool leaf=1;
  for(int v:E[u]){
    dfs(v);
    if(leaf){
      leaf=0;
      rep(i,0,1)rep(j,0,1)rep(l,0,1)rep(r,0,1){
        chkmin(dp[u][i][l][r],dp[v][j][l][r]+(i==j?C[v-1]:0));
      }
    }else{
      static ll buk[2][2][2];
      memset(buk,0x3f,sizeof buk);
      rep(i,0,1)rep(l,0,1)rep(r,0,1){
        rep(j,0,1)rep(x,0,1)rep(y,0,1){
          chkmin(buk[i][l][y],dp[u][i][l][r]+dp[v][j][x][y]+(i==j?C[v-1]:0)+(r==x?rig[u]:0));
        }
      }
      memcpy(dp[u],buk,sizeof buk);
    }
    rig[u]=rig[v];
//    printf("#### after %d (%lld)\n",v,lef[v]);
//  printf("%d : ",u);rep(i,0,1)rep(l,0,1)rep(r,0,1){
//    ll x=dp[u][i][l][r];
//    if(x<3e17)printf("[%d %d %d, %lld]\n",i,l,r,x);
//  }
  }
  if(leaf){
    dp[u][0][0][0]=0;
    dp[u][1][1][1]=0;
    rig[u]=W[cur++];
  }
}

long long place_police(vector<int> P, vector<long long> C, vector<long long> W){
  memset(dp,0x3f,sizeof dp);
  n=P.size()+1;
  E.resize(n);
  rep(i,1,n-1){
    int f=P[i-1];
    E[f].pb(i);
  }
  ::C=C,::W=W;
  dfs(0);
  ll as=1e18;
  rep(i,0,1)rep(l,0,1)rep(r,0,1){
    chkmin(as,dp[0][i][l][r]+(l==r?W.back():0));
  }
  return as;
}

//#include"grader.cpp"

详细

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