很多人一看到“CSTC”,就发颤,其实这道题就是一道超超超级水题。
不多说,上代码:
源代码 复制
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace FGF{
int n,m,V;
const int N=1e5+5;
const ll INF=0x3f3f3f3f3f3f3f3f;
struct edg{
int to,nxt,w;
}e[N<<1];
int cnt,head[N],pre[N],ro,is[N],q[N];
ll dis[N],L[N],d[N];
namespace shortcut {
bool check(ll x){
ll PN,PP,NN,NP,PX,NX,cur;
int h=1,t=0;
PN=PP=NN=NP=PX=NX=-INF;
for(int i=1;i<=V;i++) {
while(h<=t&&L[i]+d[i]-L[q[h]]+d[q[h]]>x)PX=max(PX,L[q[h]]+d[q[h]]),NX=max(NX,d[q[h]]-L[q[h]]),h++;
cur=d[i]+m-x;