上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 57 下一页

2011年7月22日

poj 3278 Catch That Cow

摘要: #include<iostream> //bfs广度优先搜索#include<deque>using namespace std;struct Node{ int data,times;}node[1000000];int n,k,p;bool visited[500000];int main(){ cin>>n>>k; deque<Node> col; if(n==k) cout<<"0\n"; else { node[0].data=n;node[0].times=0; col.push_back( 阅读全文

posted @ 2011-07-22 16:44 sysu_mjc 阅读(124) 评论(0) 推荐(0) 编辑

poj 3117 World Cup

摘要: #include<iostream> //比赛场数乘3减去分数之和#include<string>using namespace std;int main(){ int t,n,a,s; string str; while(cin>>t>>n,t) { s=0; while(t--) { cin>>str>>a; s+=a; } cout<<3*n-s<<endl; } return 0;} 阅读全文

posted @ 2011-07-22 16:43 sysu_mjc 阅读(77) 评论(0) 推荐(0) 编辑

poj 3211 Washing Clothes

摘要: #include<iostream> //0-1背包问题#include<map>#include<vector>#include<string>using namespace std;int main(){ int m,n,p,s[12],dp[200000],sum; //dp[x]=y表示总时间为x,其中在洗衣服的时间最多为 y int i,j,k; string color; while(cin>>m>>n&&m&&n) { map<string ,int> col; m 阅读全文

posted @ 2011-07-22 16:43 sysu_mjc 阅读(132) 评论(0) 推荐(0) 编辑

poj 3007 Organize Your Train part II

摘要: //题意:给定一个字符串,从任意位置把它切为两半,得到两个子串//定义子串1为s1,子串2为s2,子串1的反串为s3,子串2的反串为s4//现在从s1 s2 s3 s4中任意取出两个串组合,问有多少种不同的组合方法//限制: (1) 串Si不能和其反串组合 (2) Si+Sj与Sj+Si是两种组合方式(但未必是不同的组合方式)#include <iostream> //字符串ELFHash 哈希#include <algorithm>#include<string>using namespace std;#define M 10000 //M=100000 阅读全文

posted @ 2011-07-22 16:42 sysu_mjc 阅读(236) 评论(0) 推荐(0) 编辑

poj 3067 Japan

摘要: #include <iostream> //树状数组,同poj 2155 starsusing namespace std;const int maxm=1005;int table[maxm],link[1000010][2],t,m,n,k,i,j;int cmp(const void* a,const void* b){ if( ((int *)a)[0] == ((int *)b)[0] ) return ((int *)a)[1] - ((int *)b)[1]; else return ((int *)a)[0]-((int *)b)[0];}int lowbit(in 阅读全文

posted @ 2011-07-22 16:42 sysu_mjc 阅读(138) 评论(0) 推荐(0) 编辑

poj 2602 Superlong sums

摘要: #include <iostream> //水题,数据量很大,要用G++的getchar(),putchar(),scanf,printf超时using namespace std;char str1[1000005],str2[1000005];int main(){ int n,i; scanf("%d ",&n); for(i=0;i<n;++i) { str1[i]=getchar();getchar(); str2[i]=getchar();getchar(); } for(i=n-1;i>=0;--i) { str1[i]+=st 阅读全文

posted @ 2011-07-22 16:37 sysu_mjc 阅读(113) 评论(0) 推荐(0) 编辑

poj 2376 Cleaning Shifts

摘要: #include <iostream> //区间覆盖问题--贪心#include <algorithm>using namespace std;struct Node{ int a,b; bool operator<(const Node& other) { if(a!=other.a) return a<other.a; else return b>other.b; //当a相等时b按从大到小,作用只有:在选择第一个区间(起点s)时选择最长的那个区间 }}node[25002]... 阅读全文

posted @ 2011-07-22 16:34 sysu_mjc 阅读(138) 评论(0) 推荐(0) 编辑

poj 2481 Cows

摘要: // 题意:有n头奶牛,各自有属性[s,e],假如Si <= Sj and Ej <= Ei and Ei - Si > Ej - Sj, 则牛 i 比牛 j 强壮// 询问每头奶牛比他强的奶牛的数量#include <iostream> //一维树状数组#include <algorithm>using namespace std;const int maxn=100005;int table[maxn],tail; //table表示树状数组,下标从 1 到 tailint overlap[maxn],ans[maxn]; struct Cow { 阅读全文

posted @ 2011-07-22 16:34 sysu_mjc 阅读(124) 评论(0) 推荐(0) 编辑

poj 2275 Flipping Pancake

摘要: #include <iostream> //翻烧饼问题#include <algorithm>#include <vector>using namespace std;int list[35];vector<int> col;void flip(int p){ reverse(list,list+p); //reverse(&list[0],&list[p]); col.push_back(p);}int main(){ int pos,i,j,len; while(scanf("%d",&len)&a 阅读全文

posted @ 2011-07-22 16:33 sysu_mjc 阅读(347) 评论(0) 推荐(0) 编辑

poj 2250 Compromise

摘要: // 题意: 求最长公共子序列LCS,只不过是将传统的字符换成了字符串#include<iostream> #include<string> using namespace std;const int MAXN=105;string str1[MAXN],str2[MAXN],res[MAXN];int val[MAXN][MAXN],path[MAXN][MAXN],r1,r2,len; //r1,r2,len分别是str1,str2,res的长度int dp(int i,int j){ if(i==-1||j==-1) retu... 阅读全文

posted @ 2011-07-22 16:32 sysu_mjc 阅读(106) 评论(0) 推荐(0) 编辑

上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 57 下一页

导航