2013年7月29日

poj1458

摘要: 1 /* 最长公共子序列*/ 2 #include 3 #include 4 #include 5 using namespace std; 6 int dp[1000][1000],dir[1000][1000]; 7 char a[1000],b[1000]; 8 int LCS(int n,int m) 9 {10 int i,j;11 for(i=1;i=dp[i][j-1])20 {21 dp[i][j]=dp[i-1][j];22 dir[i][j]=0;23 ... 阅读全文

posted @ 2013-07-29 18:11 ok_boy 阅读(194) 评论(0) 推荐(0) 编辑

poj2250

摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 char a[1010][35],b[1010][35]; 8 int dir[1000][1000],dp[1000][1000]; 9 int LCS(int n,int m)10 {11 int i,j;12 for(i=1;i=dp[i][j-1])21 {22 dp[i][j]=dp[i-1][j];23 dir[i][j... 阅读全文

posted @ 2013-07-29 18:10 ok_boy 阅读(176) 评论(0) 推荐(0) 编辑

poj1068

摘要: 1 /*读懂题意:pi表示右括号前面有几个左括号, 2 wi表示与右括号配对的左括号与该右括号之间有几个左括号, 3 包括配对的,已经配对过的左括号不能再与右括号配对 4 解法:还原原来的字符串*/ 5 #include 6 #include 7 #include 8 using namespace std; 9 int main()10 {11 int i,j,k,n,m;12 int a[505],b[505],c[505];13 int t;14 scanf("%d",&t);15 while(t--)16 {17 sca... 阅读全文

posted @ 2013-07-29 18:09 ok_boy 阅读(236) 评论(0) 推荐(0) 编辑

poj1694

摘要: 1 /*给出一棵树的描述 2 第一行输入t,代表案例的个数 3 第二行一个n代表这棵树有n个节点 4 接下来n行第一个数是节点的编号,根节点编号为1,然后第二个数是节点的个数,如果为0那就没子节点,否则输入节点的 5 编号 6 方法:递归+排序 7 先求出根节点的r个子节点需要的最小石头数,然后按大到小排序r1,r2,r3..rr,另结果result初值为最大的那个 8 r1,然后剩下为remain=result-1,然后将remain从r2遍历到rr,如果都比remainxiao说明剩下的可以满足,否则结果 9 result+=ri-remain,remain=ri-1;,遍历r个数以后就. 阅读全文

posted @ 2013-07-29 18:08 ok_boy 阅读(289) 评论(0) 推荐(0) 编辑

poj2993

摘要: #include#include#includeusing namespace std;struct point { int i,j; int num; char c;}p[1000];int find(char n){ if(n=='a') return 2; if(n=='b') return 6; if(n=='c') return 10; if(n=='d') return 14; if(n=='e') return 18; if(n=='f') return 22; if(n==' 阅读全文

posted @ 2013-07-29 18:05 ok_boy 阅读(145) 评论(0) 推荐(0) 编辑

poj2996

摘要: 1 /*排序函数要写对,优先级:K,Q,R,B,N,P 2 白色的:如果优先级一样,那么按照行数大的优先,如果行数一样,那么列数小的优先 3 黑色的:如果优先级一样,那么按照行数小的优先,如果行数一样,那么列数小的优先 4 第一个在左下脚,向上数*/ 5 #include 6 #include 7 #include 8 using namespace std; 9 struct point 10 { 11 int i,j; 12 char c; 13 int num; 14 }p[1000]; 15 int cmp(const point a,con... 阅读全文

posted @ 2013-07-29 18:04 ok_boy 阅读(238) 评论(0) 推荐(0) 编辑

poj3125

摘要: /*水题,模拟排队*/#include#include#includeusing namespace std;const int maxn=10000;struct point{int index;int i;}p[maxn];int main(){int i,j,k,n,m;int t;scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);for(i=0;i<=10000;i++){p[i].index=0;p[i].i=0;}for(i=0;i<n;i++){scanf(&qu 阅读全文

posted @ 2013-07-29 18:02 ok_boy 阅读(197) 评论(0) 推荐(0) 编辑

导航