QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#164625 | #7118. Closing Time | unputdownable | Compile Error | / | / | C++17 | 2.0kb | 2023-09-05 11:24:07 | 2023-09-05 11:24:08 |
Judging History
你现在查看的是测评时间为 2023-09-05 11:24:08 的历史记录
- [2024-04-28 07:28:08]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-05 11:24:08]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-05 11:24:07]
- 提交
answer
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include "closing.h"
#include <bits/stdc++.h>
#define i64 long long
#define pii pair <i64, i64>
using namespace std;
vector <pii> E[400005];
i64 depx[400005],depy[400005];
i64 sig[400005],cnt1,cnt2;
pii val[400005];
i64 vvv[400005];
inline void dfs(i64 x,i64 f,i64*dep) {
for(pii e : E[x]) {
if(e.first==f) continue;
dep[e.first]=dep[x]+e.second;
dfs(e.first,x,dep);
}
}
inline void check(i64&R,i64&sum,i64 lim) { if(lim<0) return R=-1000000,void(); while(sum>lim) sum-=sig[R--]; }
i64 max_score(i64 n, i64 x, i64 y,i64 k, std::vector<i64> U, std::vector<i64> V, std::vector<i64> W) {
for(i64 i=0; i<n; ++i) E[i].clear(); cnt1=cnt2=0; i64 k0=k;
i64 m=U.size();
for(i64 i=0; i<m; ++i) E[U[i]].emplace_back(V[i],W[i]);
for(i64 i=0; i<m; ++i) E[V[i]].emplace_back(U[i],W[i]);
dfs(x,-1,depx);
dfs(y,-1,depy);
i64 cnt=0;
for(i64 i=0,a,b; i<n; ++i) {
vvv[i+1]=depx[i];
vvv[i+n+1]=depy[i];
if(depx[i]+depy[i]==depx[y]) {
k-=min(depx[i],depy[i]);
sig[++cnt1]=max(depx[i],depy[i])-min(depx[i],depy[i]);
++cnt;
continue;
}
if(depx[i]>depy[i]) a=depy[i],b=depx[i]-a;
else a=depx[i],b=depy[i]-a;
if(a<b) sig[++cnt1]=a,sig[++cnt1]=b;
else val[++cnt2]=(pii){a+b,a};
}
sort(val+1,val+cnt2+1);
sort(sig+1,sig+cnt1+1);
sort(vvv+1,vvv+2*n+1); vvv[2*n+1]=k0+1;
i64 p=0; i64 s1=0;
while(s1+vvv[p+1]<=k0) s1+=vvv[++p];
i64 Ans=p;
i64 R=0; i64 sum=0; sig[cnt1+1]=k+1;
while(sum+sig[R+1]<=k) sum+=sig[++R];
if(k>=0) Ans=max(Ans,R+cnt);
if(k>=0) for(i64 i=1; i<=cnt2; ++i) {
check(R,sum,k-val[i].second),Ans=max(Ans,2*i+R+cnt-1);
check(R,sum,k-=val[i].first),Ans=max(Ans,2*i+R+cnt);
}
return Ans;
}
详细
/usr/bin/ld: /tmp/cc5zrmZs.o: in function `main': implementer.cpp:(.text.startup+0x775): undefined reference to `max_score(int, int, int, long long, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)' collect2: error: ld returned 1 exit status