- 博客(22)
- 收藏
- 关注
原创 poj 2677 dp解双调tsp
//poj 2677//sep9#include #include using namespace std;const int maxN=128;struct P{ double x,y;}p[maxN];int n;double dp[maxN][maxN],dis[maxN][maxN];double solve(){ dp[1][2]=dis[1][2]; fo
2015-10-26 15:18:53 516
原创 poj 2625 概率dp
//poj 2625//sep9#include using namespace std;typedef __int64 INT;INT n,up,down;INT gcd(INT x,INT y){ return x%y==0?y:gcd(y,x%y);}void add(INT x,INT y){ if(down==0){ up=x; down=y; re
2015-10-26 11:04:17 651
原创 poj 1158 TRAFFIC LIGHTS spfa求最短路
//poj 1158//sep9#include #include using namespace std;const int maxN=312;const int maxM=30012;struct Edge{ int v,w,nxt;}edge[maxM];int S,T,n,m,e;int rc[maxN],tb[maxN],tp[maxN],d[maxN],head
2015-10-25 21:25:12 450
原创 poj 1009 Edge Detection 模拟
//poj 1009//sep9#include #include using namespace std;const int maxN=1024;struct RLE{ int v,pos; }rle_in[maxN],rle_out[maxN*8];int n,m,p,q,sum;int cmp(RLE x,RLE y){ return x.pos<y.pos;
2015-10-23 13:11:00 436
原创 poj 1010 STAMPS 枚举组合
//poj 1010//sep9#include #include using namespace std;int stamp[128],n,sum,ok,tie;struct SOL{ int types; int high; int num; int v[8];}best,now;int vis[128];void judge(){ if(now.types=
2015-10-21 15:48:24 537
原创 poj 3272 Cow Traffic dag上的dp
//poj 3272//sep9#include using namespace std;const int MAXN=5012;const int MAXM=50012;int n,m,e,rev_e;int head[MAXN],rev_head[MAXN],flag[MAXN],dp[MAXN],rev_dp[MAXN];struct EDGE{ int v,next;}
2015-10-20 20:37:14 482
原创 poj 1775 Sum of Factorials 枚举子集
//poj 1775//sep9#include using namespace std;const int MAXN=1000024;int f[20];int d[MAXN+10];int main(){ int n; f[0]=f[1]=1; for(int i=2;i<=9;++i) f[i]=f[i-1]*i; memset(d,0,sizeof(d));
2015-10-20 17:23:24 455
原创 poj 2991 Crane 线段树lazy_tag
//poj 2991//sep9#include #include using namespace std;const int MAXN=100024;const double PI=acos(-1.0);double sumx[MAXN*4],sumy[MAXN*4];int angle[MAXN],alpha[MAXN*4];void push_up(int k){ s
2015-10-19 15:39:16 401
原创 poj 3974 Palindrome 裸的最长回文子串Mancher算法O(n)
//poj 3974//sep9#include using namespace std;const int MAXN=1000024; char a[MAXN],b[2*MAXN];int p[2*MAXN];int main(){ int cases=0; while(scanf("%s",a)==1&&a[0]!='E'){ int i=0,j=0; b[j++]
2015-10-16 13:46:29 534
原创 poj 1015 Jury Compromise 01背包+输出方案
//poj 1015//sep9#includeusing namespace std;const int delta=400;int a[202],b[202];int dp[202][22][2*delta+10];int path[202][22][2*delta+10];int n,m;void print(int x,int y,int z){ if(x==0)
2015-10-15 14:58:33 416
原创 poj 3690 Constellations 二维滚动哈希匹配
//poj 3690//sep9#include #include using namespace std;typedef unsigned long long ull;const int MAXN=1024;const int MAXT=128;const int MAXP=64;const int B1=9973;const int B2=100000007;char
2015-10-15 00:07:48 653
原创 poj 1411 Calling Extraterrestrial Intelligence Again 筛素数
//poj 1411//sep9#include using namespace std;const int MAX=50024;bool vis[MAX+10];int primes[10024],num;int main(){ memset(vis,false,sizeof(vis)); num=0; for(int i=2;i<MAX;++i){ if(!vis[
2015-10-13 16:27:53 460
原创 poj 2763 Housewife Wind 动态求树上两点之间距离
题意:给一棵n分析:首先用dfs将数序列化,然后用rmq求lca,用树状数组求树上两点之间的距离和更新边。 代码://poj 2763//sep9#include #include using namespace std;const int MAXN=100024;const int LOG_MAXN=20;struct EDGE{ int idx,v,w,nx
2015-10-13 14:52:08 620 2
原创 poj 2564 Edit Step Ladders TRIE树+dp求图中最长路
//poj 2564//sep9#include using namespace std;const int MAXN=25000;int n,idx;char tmp[20],s[MAXN+10][20];int dp[MAXN+10];struct TRIE{ int c[27]; bool vis; int ids;}a[8*MAXN+10];void inse
2015-10-10 18:22:45 533
原创 poj 2404 Jogging Trails 状压dp
?/poj 2404//sep9#include using namespace std;const int MAX=INT_MAX/2;const int MAXN=16;int n,m;int deg[MAXN],d[MAXN][MAXN],dp[1<<MAXN];int rec(int s){ if(s==0) return dp[s]=0; if(dp[s]>
2015-10-10 00:19:44 607
原创 poj 1254 Hansel and Grethel 直线求交
题意:通过点和方向给出两条直线,求他们的交点。分析:裸的直线求交,向量做法可避免特殊情况的的讨论。代码://poj 1254//sep9#include #include using namespace std;const double pi=acos(-1.0);struct P{ double x,y;}a,b,c,d;double det(doub
2015-10-09 00:27:47 740
原创 poj 2250 Compromise dp求lcs+输出方案
//poj 2250//sep9#include using namespace std;struct WORD{ char s[32];}a[128],b[128];int dp[128][128],match[128][128];void print(int x,int y){ if(x==0||y==0) return ; if(match[x][y]==0){
2015-10-08 17:22:07 524
原创 poj 2288 Islands and Bridges 状压dp
//poj 2288//sep9#include using namespace std;typedef __int64 INT;INT v[16];INT dp[(1<<13)+10][13][13],path[(1<<13)+10][13][13];bool map[16][16];int n,m;INT rec(int s,int now,int pre){ if(d
2015-10-08 15:21:00 385
原创 poj 2353 Ministry 对规划方向有要求的dp
//poj 2353//sep9#includeusing namespace std;int dp[128][512],cost[128][512],path[128][512];int m,n;void print(int row,int col){ if(path[row][col]==col) print(row-1,col); else if(path[row][c
2015-10-08 00:27:02 610
原创 poj 3181 Dollar Dayz 高精度+完全背包
//poj 3181//sep9#include using namespace std;struct H { int a[10],len; void clear(){ memset(a,0,sizeof(a));len=1; } void print(){ printf("%d",a[len]
2015-10-06 23:09:47 438
原创 poj 1700 Crossing River 贪心
题意:有n个人要坐船过河,每个人需要的时间已知,有一条最多容纳两个人的船,两个人坐船的时间为两人中的较大值,求所有人过河的最少时间。分析:设4个人分别要a分析://poj 1700//sep9#include #include using namespace std;int n;int a[1024];int main(){ int cases; scan
2015-10-02 14:40:38 452
原创 poj 2068 Nim 博弈论dp
题意:给S个石子,2个队,每队n个人,每队轮流拿石子,每人能拿的最大石子数作为输入给出,问先拿的队必胜还是必败。分析:必败态的下个状态都是必胜态,必胜态的下个状态有必败态,状态明确了就能dp了,一开始定义的是dp[石子数][游戏经过步数],后来发现dp[石子数][选手编号]就可以了。代码://poj 2068//sep9#includeusing namespace st
2015-10-01 20:12:54 576
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人