摘要:
// 1028. List Sorting.cpp: 主项目文件。 #include "stdafx.h"
#include #include #include using namespace std; const int N=100003;
typedef struct Stu{ char id[7],name[9]; int score;
}Stu;
Stu stu[N];
int version; bool cmp(Stu m1,Stu m2){ if(version==1) return strcmp(m1.id,m2.id)<0; else if(versi 阅读全文
摘要:
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 阅读全文
摘要:
// 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'& 阅读全文
摘要:
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 阅读全文
摘要:
// 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 _ 阅读全文
摘要:
// 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 阅读全文
摘要:
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 阅读全文
摘要:
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" 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
A good idea excels everything.WA twice before finding my original idea is wrong,It's a good experience,I need to think sufficiently; // 1046. Shortest Distance.cpp: 主项目文件。 #include "stdafx.h"
#include const int N=100003;
int dist[N],sDist[N]; int main()
{ int n,sum=0; scanf("%d&qu 阅读全文
摘要:
data structure classical problem,study to create BST#include #include const int N=1003;
int arr[N];
typedef struct BitNode{ int data; BitNode *lchild,*rchild;
}BitNode;
bool success,tag; void createBST(BitNode *&root,int low,int high,int version){ if(!success) return; if(low=pivot) br... 阅读全文