Guest User

Untitled

a guest
Jan 21st, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <string>
  5. #include <sstream>
  6. #include <iomanip>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <ctime>
  10. #include <string.h>
  11. #include <algorithm>
  12. #include <queue>
  13. #include <stack>
  14. #include <vector>
  15. #include <map>
  16. #include <set>
  17.  
  18. using namespace std;
  19.  
  20. struct compare {
  21.     bool operator() (const string& lhs, const string& rhs) const{
  22.         int s,s1,s2,p1=0,p2=0;
  23.         while(lhs[p1]=='0')p1++;
  24.         while(rhs[p2]=='0')p2++;
  25.         s1=lhs.size(),s2=rhs.size();          
  26.         s=min(s1-p1,s2-p2);
  27.         if(s1-p1==s2-p2)
  28.             for(int x=0;x<s;x++)
  29.                 if(lhs[p1+x]!=rhs[p2+x])
  30.                     return lhs[p1+x]<rhs[p2+x];
  31.         return s1-p1<s2-p2;
  32.     }
  33. };
  34. map<string,int,compare>p;
  35. int main(){
  36.     char c[1500];
  37.     int n,k,pp=0;
  38.     scanf("%d %d",&n,&k);
  39.     for(int x=0;x<n;x++){
  40.         scanf("%s",c);
  41.         p[c]++;
  42.     }
  43.     int a;
  44.     map<string,int,compare>::iterator xx=p.begin();
  45.     while(xx->second>1)
  46.         xx++;
  47.     for(int y=1;y<k;y++){
  48.         while(xx->second>1)xx++;
  49.         xx++;
  50.     }
  51.     printf("%s\n",xx->first.c_str());
  52. }
Add Comment
Please, Sign In to add comment