摘要:
#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#define min(a,b) (a)>(b)?(b):(a)#define max(a,b) (a)>(b)?(a):(b)#define inf 99999999using namespace std;int cnt;int source,N;int sink,ans;int c[5000];int H[500410];int d[5041];struct egde{ int u,v,c,n 阅读全文
摘要:
#include<cstdio>#include<iostream>#define min(a,b) (a)>(b)?(b):(a)#define max(a,b) (a)>(b)?(a):(b)using namespace std;struct point{ double x,y;};struct segment{ point a,b; };segment s[1000];double Direction(point i,point j,point k){ double tempx1=k.x-i.x; double tempy1=k.y-i.y; dou 阅读全文
摘要:
#include<cstdio>#include<iostream>#include<algorithm>#define inf 99999999#define max(a,b) (a)>(b)?(a):(b) using namespace std;int S,sink,oo,T,cnt,n,ans,sum;int c[1000001];int H[1000001];int d[1000001];struct edge{ int u,v,c,next;};edge a[1000001];void init(){ int i; for(i=0;i< 阅读全文
摘要:
#include<cstdio>#include<cstring> #include<iostream>using namespace std;long long need[1000010],now[1000010];int main(){ int T,cases=1; scanf("%d",&T); while(T--) { int n,m,i,t; scanf("%d%d",&n,&m); long long res=0,ans=0; memset(need,0,sizeof(need)); 阅读全文
摘要:
View Code #include<iostream>#include<stack>#include<cstdio>#include<cstring>using namespace std;struct node{ int id1; char b; };node bracket[1000010];char str[1000010];int cnt[1000010];int main(){ char te,ch; int t,cases=1,k,temp; stack<node>q; scanf("%d",& 阅读全文
摘要:
/*对于菜鸟,第一次接触这种大型算法,应该抽出一大段时间研究,研究这个算法我认为要有DIJ和Floyd的铺垫。搜集各路资料,大概有以下几个要点。1.SPFA(Shortest Path Faster Algorithm)是Bellman-Ford算法的一种队列实现,减少了不必要的冗余计算。(啊,亲,什么是Bellman-Ford?大致:1对每条边进行|V|-1次Relax操作;2如果存在(u,v)∈E使得dis[u]+w<dis[v],则存在负权回路;否则dis[v]即为s到v的最短距离,pre[v]为前驱。)2.算法大致流程是用一个队列来进行维护。 初始时将源加入队列。 每次从队列中取 阅读全文