自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Collider

愿所有刷过的题都成为你比赛中信手拈来的水题.

  • 博客(20)
  • 收藏
  • 关注

原创 POJ2112-Optimal Milking

二分最大流答案,注意上界是INF而不是200.#include <cstdio>#include <cstring>#include <vector>#include <queue>#include <algorithm>using namespace std;const int maxk = 30 + 5;const int maxc = 200 + 5;const int maxv =

2016-10-31 22:33:22 294

原创 POJ1274-The Perfect Stall

裸的二分图匹配问题。 两种做法,第一种是建图转换成最大流流的问题求解,另一种直接用二分图匹配模板。 最大流:#include <cstdio>#include <cstring>#include <vector>#include <queue>#include <algorithm>using namespace std;const int maxn = 400 + 5;const l

2016-10-30 21:38:01 214

原创 POJ2987-Firing

利用Dinic求最小割,求最大权闭合图。 其中最大权=正权和-最小割,即最大裁员收益。 在求出最小割之后,遍历搜索残余网络的顶点个数即可求出裁员的个数。数据太大需要用long long。 计算残余网络的顶点个数时要去掉源点。#include <cstdio>#include <cstring>#include <vector>#include <queue>#include <algo

2016-10-30 20:23:02 267

原创 HDU5916-Harmonic Value Description

给定一个n和k,要求组合1-n之间的数使它们gcd为第k小。 组合时相邻两数的gcd一定为1,因此要使得组合第k小,就可以将k与2k相邻,其余的各项相邻的数之间gcd为1. 可以这样排序: 2, 3, 4, … ,k, 2k, 2k+1, 2k+2, …, n, 1, k+1, k+2, … ,2k-1 其中区间[2, k],[2k+1, n],[1, 2k-1]都连续,因此区间内相邻gcd

2016-10-28 19:36:24 505

原创 HDU5918-Sequence I

搏一搏,单车变摩托! 虽然是KMP但是可以暴力水过。#include <cstdio>#include <cstring>const int maxn = 1000000 + 5;const int maxm = 1000000 + 5;int a[maxn];int b[maxm];int main(int argc, char const *argv[]) { int T;

2016-10-28 17:20:35 330

原创 POJ1961-Period

利用KMP算法对该字符串处理计算出它的部分匹配表(next) 利用next求出它的循环节。#include <cstdio>const int maxn = 1000000 + 10;char s[maxn];int next[maxn];int n;void get_next() { int k = 0; next[0] = 0; for (int q = 1; q <

2016-10-28 16:42:36 232

原创 HDU5912-Fraction

模拟题,自下而上模拟分子和分母。#include <cstdio>int a[10];int b[10];int gcd(int a, int b) { return b ? gcd(b, a % b) : a;}int main(int argc, char const *argv[]) { int T; scanf("%d", &T); for (int t

2016-10-26 19:56:39 419

原创 POJ3373-Changing Digits

Dfs+强剪枝。 discuss里有一组很好的数据: 535064 9084 答案为:535956 先从m < n开始搜,再从n > m搜索,并用f数组记录剪枝。#include <cstdio>#include <cstring>char n[105];int k;int m[105];int mod[105][10];int f[105][10000+5]; //f[p

2016-10-26 16:27:34 287

原创 POJ1691-Painting A Board

很有趣的搜索题。 将每个矩阵作为一个顶点,矩阵i在矩阵j的上方就从i到j连边,并且记录每个顶点的入度。 Dfs一个矩阵时,将它下方的矩阵入度减一,入度为0时即可以涂色的位置。 特么这题输入的是y和x!#include <cstdio>#include <cstring>struct Rectangle { int lx, ly, rx, ry, color;};Rectangle

2016-10-24 20:16:12 351

原创 POJ1724-ROADS

给定k元钱,要求满足在k元钱内的最短路。 虽然是最短路问题,但是由于它的限制条件,在设计算法时也无需更新最短路,因此采用Bfs与优先队列结合的算法,通过优先队列不断取出符合条件的“最短路”。#include <cstdio>#include <vector>#include <queue>#include <algorithm>using namespace std;const int ma

2016-10-23 20:04:12 252

原创 POJ3411-Paid Roads

中级搜索题。 判断没有重复的回路即可,由于一共10个顶点,最少3个顶点1个回路,设想有一个顶点,图中所有的回路都与它有关,那么这个顶点最多被经过4次,因此搜索时只要记录每个点路过的次数并判断即可。#include <cstdio>const int INF = 12345678;struct Road { int a, b, c, p, r;};Road way[12];int vis

2016-10-23 19:12:27 278

原创 POJ3267-The Cow Lexicon

dp[i]表示从i到message末尾最少需要删去的字符数。 枚举每个单词进行匹配,不断更新最小删去数。#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char mesg[400];char dict[650][50];int dp[400];int main(int argc, char

2016-10-21 20:27:12 218

原创 POJ1054-The Troublesome Frog

两点确定一条直线,所以枚举两个点即可。#include <cstdio>#include <algorithm>using namespace std;typedef pair<int, int> P;const int maxn = 5000 + 5;P flat[maxn];int r, c, n;int search(int x, int y, int dx, int dy) { i

2016-10-21 17:51:55 349

原创 POJ1836-Alignment

枚举并分别LIS即可。#include <cstdio>#include <algorithm>using namespace std;const int maxn = 1000 + 5;const double INF = 3.0;double line[maxn];double dp1[maxn];double dp2[maxn];int main() { int n; s

2016-10-19 18:10:51 289

原创 POJ1837-Balance

乍一看是一道暴搜题,但是暴搜显然会超时。 正确做法是01背包,引入平衡度的概念,用dp的方式统计求解。#include <cstdio>int h[25];int w[25];//dp[i][j]表示挂满前i个钩码时,平衡度为j的挂法的个数int dp[25][15000+5];int main() { int c, g; scanf("%d%d", &c, &g);

2016-10-18 16:55:51 276

原创 POJ2135-Farm Tour

将该问题转换为求从1号顶点到n号顶点的两条没有公共边的路径,即求流量为2的最小费用流。#include <cstdio>#include <vector>#include <queue>#include <algorithm>using namespace std;const int maxv = 1000 + 10;const int INF = 350000000 + 10;typede

2016-10-14 19:56:27 284

原创 POJ3469-Dual Core CPU

将问题分成S,T两个集合,转换为最小割进行解决。 在核A上执行的模块记为集合S,在核B上执行的模块集合为T,s为源点,t为汇点。在核A上执行所需费用是在顶点属于集合S时所产生的费用,因此将每个模块向t连边。相同的,源点s向集合T连边。 当两个模块在不同的核上运作的时候,只需在这两个模块之间连上一条双向边即可。 假如s和模块a之间的边是割,那么a在s上被处理,否则a在t上被处理,s能到达的点在t

2016-10-14 19:27:03 374

原创 POJ3281-Dining

按照食物,牛,饮料并自定源点s和汇点t建图,用最大流求解。 图中牛的节点为2 * n个,这样能使每头牛最多一份食物一份饮料。#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <algorithm>using namespace std;const int maxn = 100 + 5;

2016-10-14 18:35:51 226

原创 POJ3041-Asteroids

把所有点的x,y坐标作为二分图的U和V,并将这个问题转化为寻找二分图的最小顶点覆盖。 对于二分图而言,|最大匹配| = |最小顶点覆盖|。#include <iostream>#include <cstring>#include <vector>using namespace std;const int maxn = 1000 + 10;int n;vector<int> G[maxn];

2016-10-11 17:31:23 212

原创 POJ1273&&HDU1532-Drainage Ditches

最大流入门题,不用想就知道用Dinic算法。 0ms稳!#include <cstdio>#include <cstring>#include <vector>#include <queue>using namespace std;const int maxn = 200 + 10;const int INF = 10000000 + 10;struct edge { int to

2016-10-09 20:25:03 312

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除