QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#308213#6659. 외곽 순환 도로 2SampsonYWCompile Error//C++141.6kb2024-01-19 18:54:052024-01-19 18:54:05

Judging History

你现在查看的是测评时间为 2024-01-19 18:54:05 的历史记录

  • [2024-08-26 15:52:07]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:33ms
  • 内存:28156kb
  • [2024-01-19 18:54:05]
  • 评测
  • [2024-01-19 18:54:05]
  • 提交

answer

#include <bits/stdc++.h>
#define il inline
#define re register
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
using namespace std;
#define N 100005
il void chkmin(ll &x, ll y) {(x > y) && (x = y);}
int n, m; ll v[N];
vector<pair<int, ll>> son[N];
ll dp[N][2][2][2], tmp[2][2][2];
#define FOR(i, L, R) for(re int i = (L); i <= (R); ++i)
#define FR(a, b, c) FOR(a, 0, 1) FOR(b, 0, 1) FOR(c, 0, 1)
il void dfs(int x) {  
  if(son[x].empty()) {
    FOR(k, 0, 1) dp[x][k][k][k] = 0; ++m; return ;
  }
  bool F = 0; ll d;
  for(auto it : son[x]) {
    int y = it.fi; ll w = it.se; dfs(y);
    memcpy(tmp, dp[x], sizeof(tmp));
    memset(dp[x], 0x7f / 2, sizeof(dp[x]));
    if(!F) FOR(A, 0, 1) FR(a, b, c)
      chkmin(dp[x][A][b][c], dp[y][a][b][c] + (A == a) * w);
    else FR(A, B, C) FR(a, b, c)
      chkmin(dp[x][A][B][c], tmp[A][B][C] + dp[y][a][b][c] + (A == a) * w + (C == b) * d);
    F = 1, d = v[m];
    // cerr << "edge " << x << " " << y << " " << d << "\n";
  }
}
long long place_police(vector<int> P, vector<long long> C, vector<long long> W) {
  n = SZ(P) + 1;
  for(re int i = 0; i < n - 1; ++i)
    son[P[i] + 1].eb(i + 2, C[i]);
    // cerr << P[i] + 1 << " " << i + 2 << " " << C[i] << "\n";
  for(auto x : W) v[++m] = x;
  memset(dp, 0x7f / 2, sizeof(dp));
  m = 0, dfs(1); ll ans = 1e18;
  // cerr << m << "\n";
  // FOR(x, 1, n) FR(a, b, c) cerr << x << "," << a << "," << b << "," << c << " = " << dp[x][a][b][c] << "\n";
  FR(a, b, c) chkmin(ans, dp[1][a][b][c] + (b == c) * v[m]);
  return ans;
}

Details

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