Algorithm improves identity card sort time limit: 1.0s memory limit: 256.0MBProblem description the Security Bureau searched for a batch of (n) ID numbers and wanted to sort them from large to small by date of birth, and if they had the same date, they were sorted by ID number size. The ID number is 18 digits and the date of birth is 7th through 14th input format the first line an integer n, indicating that there are N ID numbers
The remaining n lines, one ID number per line. The output format is based on the date of birth from the largest to the small sort of social security number, one sample per line input 5
466272307503271156
215856472207097978
234804580401078365
404475727700034980
710351408803093165 Sample Output 404475727700034980
234804580401078365
215856472207097978
710351408803093165
466272307503271156 data size and conventions n<=100000
1#include <iostream>2#include <algorithm>3#include <vector>4 using namespacestd;5 intcmpstringAstringb) {//Custom Sort Functions6 stringBira = A.substr (6,8); 7 stringBIRB = B.substr (6,8); 8 if(Bira! =BIRB)9 returnBira >BIRB;Ten Else One returnA >b; A return 0; - } - intMain () { the intN; -scanf"%d",&N); -vector<string> V (n);//defines a container of type string: V, container size n - for(intI=0; i<n; i++) +Cin>>V[i]; -Sort (V.begin (), V.end (), CMP);//call your own defined sort function + for(intI=0; i<n; i++) Acout<<v[i]<<Endl; at return 0; -}
C language/ID card sort