Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
有大神知道这题为什么用map会超时么??数组线性查找0ms过。区别就是注释那3行char answer[83682][6]; //map<string,int> ans; void MakeAns() { char word[7]; int start = 5,i; memset(word,'a'-1,sizeof(word)); word[6] = 'z'+1; word[5] = 'a'; for(int no = 1; no <= 83681;no++) { i = 0; for(int j = start; j < 6; j++) answer[no][i++] = word[j]; answer[no][i] = 0; /*string s(word+start,word+6); ans[s] = no;*/ word[5]++; for( i = 5; i > 0 && word[i] >= word[i+1]; i--) { word[i]--; word[i-1]++; } for( ;i + 1 < 6; i++) { if( i < start ) { start = i; } word[i+1] = word[i] + 1; } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator