01 2013 档案
摘要:http://poj.org/problem?id=1836打了一堆 网络连接失败 。。不打了View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 int dp1[1010],dp2[1010],h[1010]; 8 int main() 9 {10 int i,j,k,n;11 double he[1010];12
阅读全文
摘要:http://poj.org/problem?id=1276第一种解法 http://blog.csdn.net/lyy289065406/article/details/6648102代码View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 using namespace std; 6 int c[20],w[20],num[20],cc[100010],dp[100010]; 7 int main() 8 {
阅读全文
摘要:http://poj.org/problem?id=2676一列一列的放 判断是否符合条件View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 using namespace std; 6 char s[20][20]; 7 int vx[20][20],vy[20][20],vis[20][20]; 8 int judge(int x,int y) 9 { 10 if(x>=0&&x<
阅读全文
摘要:http://poj.org/problem?id=1129四色定理 最多有四色 从1到四搜View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 using namespace std; 6 int n,w[100][100],co[100],mi,flag; 7 void dfs(int x,int v) 8 { 9 int i,j,f,k=v;10 if(flag)11 return ;12 if(x>n
阅读全文
摘要:http://poj.org/problem?id=2531把第i个节点 放在A集合中 加上没有放在A集合中的节点与之相连的数值 减去已经放在A节点中与之相连的数值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int num[25][25],n,va[50],vb[50],ma,sum; 6 void dfs(int x,int sum) 7 { 8 int i; 9 va[x] = 1;10 for(i = 1
阅读全文
摘要:http://poj.org/problem?id=1416乱七八糟的改,乱七八糟的错,最后过了样例 1A了 。对于每个分割开的数来说 有几种组合方式 搜下去View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define INF 10000000 5 using namespace std; 6 int n,m,num[10],sum,g,vis[10],di,tt,mi,f; 7 char oo[10][10],o[10][10]; 8 void dfs(in
阅读全文
摘要:http://poj.org/problem?id=3414六种情况 搜一下View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 struct node 6 { 7 int ca,cb; 8 int flag,num; 9 int op,ob; 10 }q[1000000]; 11 int a,b,c,vis[110][110],num[100000],g; 12 void put(int x,int y) 13 ...
阅读全文
摘要:http://poj.org/problem?id=3083纠结了好久 被它的转向搞晕 了WA两次 加一else AC。。设置四个方向 初始化方向自己算出来 初始化在数组中 dfs+bfs左 就是当前方向向左 左走不动就逆时针走下一个方向 依次类推 右同样的方式View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char s[50][50],so[2]; 6 int pr[7],dis[4][2]={-1,0,0,-1,
阅读全文
摘要:http://poj.org/problem?id=1442题意很难懂 题挺巧妙的 建立两个优先队列 一个从小到大 另一个从大到小 随时更新两队中的值 使其为1~i 和i+1~mView Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 int num[30010],op[30010]; 7 int main() 8 { 9 int n,m,i,j,k,g;10 while(cin
阅读全文
摘要:http://poj.org/problem?id=2442题解http://www.cnblogs.com/372465774y/archive/2012/07/09/2583866.html本来写的二维数组 ,直接対一维排序 不知道为嘛一直WA 只好该为一维的 就AC了View Code 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int num1[2005],num2[2005]; 8 bool cmp(int a,int b) 9 {10 return a>t...
阅读全文
摘要:http://poj.org/problem?id=2002刚开始hash的两点 TLE了 又改为一点 已知对角两点 求令两点View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 #define MOD 977777 6 int head[1000010],v[1000010],next[1000010],num[1000010][2],t,f[1010][1010]; 7 struct node 8 { 9 int x,
阅读全文
摘要:http://poj.org/problem?id=1840枚举 xi不等0.View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 #define MOD 97777 6 #define size 1000010 7 int t,head[size],next[size],v[size],num[size][2]; 8 void init() 9 {10 t =0 ;11 memset(head,-1,sizeof(hea
阅读全文
摘要:http://poj.org/problem?id=3274网上题解数组sum[i][j]表示从第1到第i头cow属性j的出现次数。所以题目要求等价为:求满足sum[i][0]-sum[j][0]=sum[i][1]-sum[j][1]=.....=sum[i][k-1]-sum[j][k-1] (j<i)中最大的i-j将上式变换可得到sum[i][1]-sum[i][0] = sum[j][1]-sum[j][0]sum[i][2]-sum[i][0] = sum[j][2]-sum[j][0]......sum[i][k-1]-sum[i][0] = sum[j][k-1]-sum[
阅读全文
摘要:View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int board[110][110]; 6 int di,dj,xi,xj,n,m,num,dis[4][2] = {0,1,0,-1,1,0,-1,0}; 7 void dfs(int v,int x,int y) 8 { 9 int i,tx,ty,flag = 0;10 if(v>10)11 return ;12 for(i = 0 ; i < 4
阅读全文
摘要:http://poj.org/problem?id=3087一道模拟题折腾了好久View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<map> 6 using namespace std; 7 map<string,int>ff; 8 int main() 9 {10 int i,j,k,n;11 char s1[110],s2[110],s[300],ss[300];1
阅读全文
摘要:http://poj.org/problem?id=2418 trie树,有非空格、字母的字符View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 typedef struct node 8 { 9 int num;10 struct node *next[130];11 node()12 {13 memset(n
阅读全文
摘要:http://poj.org/problem?id=3020最小路径覆盖,拆点,总结点数 = 匹配数*2+未匹配节点,所以所用天线数就等于匹配数+未匹配数=总结点-匹配数。由于拆点后,多加了边,匹配数变成了原来的2倍,有向图-》无向图,匹配数增加的是一样的。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 int link[500],map[500][500],ma[50
阅读全文
摘要:http://poj.org/problem?id=1422题意:一个镇上有很多街道,很多十字路口,无循环,把伞兵放在各个十字路口上,使之能把所有的街道都走过,求最小的伞兵数。最小路径覆盖=节点数-最大匹配。模板题View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int map[200][200],link[200],vis[200]; 6 int find(int x,int n) 7 { 8 int i,j; 9
阅读全文
摘要:http://poj.org/problem?id=2226模板抄错,结果错了一下午。将连续横行上的*和连续纵桁上点分别看做两个点集,连接两集合中点的边就是图中的点。即求最小顶点覆盖最多的边。最小点覆盖=最大匹配。有篇图片的讲解,挺好,很形象。http://ip96cns.blog.163.com/blog/static/170095192201117465473/View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 in
阅读全文