QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141471 | #6659. 외곽 순환 도로 2 | penguinman# | Compile Error | / | / | C++17 | 2.8kb | 2023-08-17 14:39:24 | 2024-07-04 01:46:43 |
Judging History
你现在查看的是测评时间为 2024-07-04 01:46:43 的历史记录
- [2024-07-04 01:46:43]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-17 14:39:24]
- 提交
answer
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define mp std::make_pair
#define mtp std::make_tuple
constexpr ll inf = (1ll<<60);
struct union_find{
ll N;
vi par, sz;
union_find(ll n): N(n){
par.resize(N);
sz.resize(N,1);
rep(i,0,N) par[i] = i;
}
ll root(ll now){
if(par[now] == now) return now;
return par[now] = root(par[now]);
}
void merge(ll u, ll v){
u = root(u);
v = root(v);
if(u == v) return;
if(sz[u] > sz[v]) std::swap(u,v);
sz[v] += sz[u];
sz[u] = 0;
par[u] = v;
}
bool same(ll u, ll v){
return root(u) == root(v);
}
};
long long place_police(vector<int> P, vector<long long> C, vector<long long> W){
ll N = P.size()+1;
vii edge(N), weight(N);
vi par(N,-1), wpar(N,inf);
rep(i,1,N){
edge[P[i-1]].pb(i);
weight[P[i-1]].pb(C[i-1]);
par[i] = P[i-1];
wpar[i] = C[i-1];
}
vi ord;
vi left(N), right(N);
std::function<void(ll)> dfs = [&](ll now){
left[now] = ord.size();
ord.pb(now);
for(auto next: edge[now]){
dfs(next);
}
right[now] = ord.size();
ord.pb(now);
};
dfs(0);
ll K = W.size();
vi V;
rep(i,0,N){
if(left[i] == right[i]-1) V.pb(i);
}
assert(V.size() == K);
vi ml(K), mr(K), mm(K);
rep(i,0,K){
ml[i] = mr[i] = inf;
mm[i] = W[i];
ll dist = 0;
{
ll now = V[i];
ll idx = right[now];
while(true){
ml[i] = std::min(ml[i], wpar[now]);
dist++;
if(ord[idx+1] != par[now]) break;
idx++;
now = par[now];
}
}
{
ll now = V[(i+1)%K];
ll idx = left[now];
while(true){
dist++;
mr[i] = std::min(mr[i], wpar[now]);
if(ord[idx-1] != par[now]) break;
idx--;
now = par[now];
}
}
if(dist%2) mm[i] = 0;
//cout << ml[i] << " " << mr[i] << " " << mm[i] << ln;
}
ll ans = 0;
rep(i,0,K){
ans += std::min(ans, std::min(mr[i], ml[(i+1)%K]));
}
return ans;
}
详细
cc1plus: fatal error: implementer.cpp: No such file or directory compilation terminated.