摘要:
// 1051. Pop Sequence.cpp: 主项目文件。 #include "stdafx.h"
#include #include using namespace std; stack S;
int stackMaxSize,arrMaxSize; void readRemain(int rem){ int temp; for(int i=0;istackMaxSize-1){ return false; } } if(curPos==arrMaxSize+1){ return false; } curPos++; ... 阅读全文
摘要:
Two arrays:NC[],NP[]Supposed that two points (l1 and r1)start from the head and the tail of the array of NC seperately,in a similar way,exists two points(l2 and r2)points to the the head and end of the array of NP.l1 and l2 move to the right step by step guaranted that nc[l1]0 and np[r2]>0,otherw 阅读全文
摘要:
// 1019. General Palindromic Number.cpp: 主项目文件。 #include "stdafx.h"
#include bool isPalindromic(int *arr, int length){ for(int i=0,j=length-1;i=0;i--){ if(i!=cnt-1) printf(" "); printf("%d",aa[i]); } printf("\n"); return 0;
} 阅读全文
摘要:
// 1012. The Best Rank.cpp: 主项目文件。 #include "stdafx.h"
#include #include #include using std::sort; const int N=10003;
typedef struct Stu{ char id[8]; int A,C,M,E; int rank[4];
}Stu;
Stu stu[N];
int n,version; bool cmp(Stu m1,Stu m2){ if(version==0) return m1.A>m2.A; else if(version==1)
阅读全文
摘要:
// 1011. World Cup Betting.cpp: 主项目文件。 #include "stdafx.h"
#include char getKey(int pos){ if(pos==0) return 'W'; else if(pos==1) return 'T'; else return 'L';
} int main()
{ double res=1.0; for(int i=0;imax) max=temp,maxf=j; } printf("%c ",getKey(maxf)); re 阅读全文
摘要:
// 1008. Elevator.cpp: 主项目文件。 #include "stdafx.h"
#include int main()
{ int n; scanf("%d",&n); int sum=sum=5*n,pre=0; for(int i=0;ipre) sum+=6*(temp-pre); else sum+=4*(pre-temp); pre=temp; } printf("%d\n",sum); return 0;
} 阅读全文
摘要:
// 1031. Hello World for U.cpp: 主项目文件。 #include "stdafx.h"
#include #include int main()
{ int n1,n2; const int N=83; char ss[N][N],str[N]; for(int i=0;in1) n1=k; } } n2=length+2-2*n1; int cnt=0; for(int i=0;i=0;j--) ss[j][n2-1]=str[cnt++]; for(int i=0;i<n1;i++){ ss[i][n2]='... 阅读全文
摘要:
http://ac.jobdu.com/problem.php?pid=1347用getchar读取数据居然可以少这么多,比起scanf整整少了320ms并查集优化:(1)路径压缩我们找到最久远的祖先时“顺便”把它的子孙直接连接到它上面int findSet(int x){ if(fa[x]==-1) return x; int ret=findSet(fa[x]); fa[x]=ret; return ret;
}(2)Rank合并合并时将元素所在深度低的集合合并到元素所在深度高的集合void unionSet(int x,int y,int dd){ int root1=fi... 阅读全文
摘要:
study disjoint-set data stucture:the key of solving this problem is the strategy to set and compute every equivalence class‘s member numbers.// 1034. Head of a Gang.cpp: 主项目文件。 #include "stdafx.h"
#include #include #include #include #include #include #include using namespace std; const int 阅读全文
摘要:
To find the first common node on the two link list;// 题目1468:Sharing.cpp: 主项目文件。 //#include "stdafx.h"
#include #include using namespace std; const int N=100003; typedef struct Node
{ int add,next;
}Node;
Node node[N];
Node list1[N],list2[N];
int n; bool cmp(Node m1, Node m2)
{ return m1.a 阅读全文