分析
好生优秀的一道建模题
一个人打开了某几个猪圈,就相当于在这个时间段把这些猪圈给“合并” 了。 然后后面有人如果要打开其中的某一个,只用找到合并的这个点,然后 连一条边即可,相当于里面的猪都可以被调换过来。 对于每个猪圈维护 lasti,表示最后访问的时间,然后每次连边接到 last, 再把 last 更新即可。
但实际上并不需要每次合并都新建一个点,直接合并到顾客身上就好了
傻逼的乱剪枝,导致每次数据都没读入完全,不停的TLE
代码
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#define in read()
#define M 2000000
#define inf 0x3f3f3f3f
#define N 2109
using namespace std;
inline int read(){
char ch;int f=1,res=0;
while((ch=getchar())<'0'||ch>'9') if(ch=='-') f=-1;
while(ch>='0'&&ch<='9'){
res=(res<<3)+(res<<1)+ch-'0';
ch=getchar();
}
return f==1?res:-res;
}
int n,m,S,T;
int nxt[M],to[M],cap[M],head[N],c

835

被折叠的 条评论
为什么被折叠?



