cjweffort

博客园 首页 联系 订阅 管理
上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页

2013年3月13日

摘要: merge with recursion.// 1029. Median(merge version).cpp: 主项目文件。 #include "stdafx.h" #include const int N=1000003; int list1[N],list2[N],mer[2*N]; int cnt; void read(int *list,int length){ for(int i=0;i<length;i++) scanf("%d",list+i); } void merge(int &l1,int h1,int &l2 阅读全文
posted @ 2013-03-13 23:40 cjweffort 阅读(151) 评论(0) 推荐(0) 编辑

摘要: // 1035. Password.cpp: 主项目文件。 #include "stdafx.h" #include #include const int N=1003; typedef struct Info{ char name[13],password[13]; }Info; Info info[N]; bool change(char *pWord1,char *pWord2){ bool tag=false; strcpy(pWord2,pWord1); for(char *cur1=pWord1,*cur2=pWord2;*cur1!='\0'& 阅读全文
posted @ 2013-03-13 22:16 cjweffort 阅读(132) 评论(0) 推荐(0) 编辑

摘要: use dijkstral algorithm to find the shortest path whose cost is always minimum.(dynamic array version)// 1030. Travel Plan.cpp: 主项目文件。 #include "stdafx.h" #include #include #include using std::vector; const int INF=0x6fffffff; const int N=503; typedef struct Edge{ int to,dd,cc; Edge(int _t 阅读全文
posted @ 2013-03-13 22:14 cjweffort 阅读(130) 评论(0) 推荐(0) 编辑

摘要: // 1036. Boys vs Girls.cpp: 主项目文件。 #include "stdafx.h" #include #include const int INF=103; struct Node{ char name[13],gender[3],id[13]; int scores; Node(char *gender){ if(strcmp(gender,"M")==0) scores=INF; else scores=-INF; } void update(char *_name,char *_gender,char *_id,int _ 阅读全文
posted @ 2013-03-13 20:19 cjweffort 阅读(165) 评论(0) 推荐(0) 编辑

摘要: // 1041. Be Unique.cpp: 主项目文件。 #include "stdafx.h" #include #include const int arrMax=100003; const int N=10003; int arr[arrMax],hash[N],pos[N]; int main() { int n; scanf("%d",&n); memset(hash,0,sizeof(hash)); memset(pos,0,sizeof(pos)); for(int i=0;i<n;i++){ scanf("%d 阅读全文
posted @ 2013-03-13 18:51 cjweffort 阅读(170) 评论(0) 推荐(0) 编辑

摘要: new criterion of sorting.// 1038. Recover the Smallest Number.cpp: 主项目文件。 #include "stdafx.h" #include #include #include using namespace std; const int N=10003; const int Dmax=9; typedef struct Node{ char str[Dmax]; }Node; Node node[N]; int num[N]; bool cmp(Node m1,Node m2){ char *str1=new 阅读全文
posted @ 2013-03-13 16:14 cjweffort 阅读(142) 评论(0) 推荐(0) 编辑

摘要: Need to improve the skill ofthe ability of string processing.// 1042. Shuffling Machine.cpp: 主项目文件。 #include "stdafx.h" #include #include const int N=55; char oriStr[N][4]={" ","S1","S2","S3","S4","S5","S6","S7" 阅读全文
posted @ 2013-03-13 11:44 cjweffort 阅读(138) 评论(0) 推荐(0) 编辑

摘要: Classical dynamic programming:find the longest increasing subsequence.// 1045. Favorite Color Stripe.cpp: 主项目文件。 #include "stdafx.h" #include #include #define max(a,b) a>b?a:b; const int N=203; int hash[N]; const int arrMax=10003; int arr[arrMax]; int cnt; int dp[arrMax]; int longestInc 阅读全文
posted @ 2013-03-13 09:48 cjweffort 阅读(175) 评论(0) 推荐(0) 编辑

摘要: Two points (proposed to be low and high )both start to point the begining of the array,If current subsequence sum is more than the need sum,low++;If current subsequence sum is less than the need sum,high++;If current subsequence sum is equal to the need sum,print the current subsequence;At the end,i 阅读全文
posted @ 2013-03-13 09:45 cjweffort 阅读(129) 评论(0) 推荐(0) 编辑

摘要: Traverse the array,every times start from the current postion extend to both sides.// 1040. Longest Symmetric String.cpp: 主项目文件。 #include "stdafx.h" #include #include const int N=1003; char str[N]; int isSymmetric(char *str,int length){ int max=0; for(int i=0;i=0&&highmax) max=dist 阅读全文
posted @ 2013-03-13 00:53 cjweffort 阅读(121) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页