During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the kids loved candies very much and often compared t…
Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows are standing in the same order as they are numbered, and sin…
Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the kids loved candies very much and ofte…
题目大意 n个点 m条描述 农场 a 比农场 b 至少多种植了 c 个单位的作物. 农场 a 比农场 b 至多多种植了 c 个单位的作物. 农场 a 与农场 b 种植的作物数一样多. 题解 差分约束裸题 可以把m条描述转换成一张图 ai-bi≥c--->bi-ai≤-c ai向bi连边权值为-c ai-bi≤c bi向ai连边 权值为c ai-bi≥0并且ai-bi≤0所以ai和bi之间连双向边.... 开始我不明白为什么要虚拟一个0点...原来图可能不连通.... 判断负环...要用sp…
Code: #include<cstdio> #include<queue> using namespace std; const int N=10000+233; const int INF=10000000; int head[N],to[N<<1],nex[N<<1],val[N<<1],vis[N],d[N]; int cnt; void add_edge(int u,int v,int c) { nex[++cnt]=head[u],h…
// #include<iostream> #include<cstring> #include<queue> #include<stack> #include<stdio.h> using namespace std; const int INF=0x3f3f3f3f; ,M=; int h[N],e[M],ne[M],w[M],idx; int st[N]; int dist[N]; int n,m; bool vis[N]; int Sca…
\(if \ a - b <= c, AddEdge(b, a, c)\) Be careful, MLE is not good. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #define R(a,b,c) for(register int a = (b); (a) <= (c); ++…
King Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8660 Accepted: 3263 Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound king…
Candies Time Limit: 1500MS Memory Limit: 131072K Total Submissions: 20067 Accepted: 5293 Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large b…