Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <sstream>
- #include <iomanip>
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctime>
- #include <string.h>
- #include <algorithm>
- #include <queue>
- #include <stack>
- #include <vector>
- #include <map>
- #include <set>
- using namespace std;
- struct compare {
- bool operator() (const string& lhs, const string& rhs) const{
- int s,s1,s2,p1=0,p2=0;
- while(lhs[p1]=='0')p1++;
- while(rhs[p2]=='0')p2++;
- s1=lhs.size(),s2=rhs.size();
- s=min(s1-p1,s2-p2);
- if(s1-p1==s2-p2)
- for(int x=0;x<s;x++)
- if(lhs[p1+x]!=rhs[p2+x])
- return lhs[p1+x]<rhs[p2+x];
- return s1-p1<s2-p2;
- }
- };
- map<string,int,compare>p;
- int main(){
- char c[1500];
- int n,k,pp=0;
- scanf("%d %d",&n,&k);
- for(int x=0;x<n;x++){
- scanf("%s",c);
- p[c]++;
- }
- int a;
- map<string,int,compare>::iterator xx=p.begin();
- while(xx->second>1)
- xx++;
- for(int y=1;y<k;y++){
- while(xx->second>1)xx++;
- xx++;
- }
- printf("%s\n",xx->first.c_str());
- }
Add Comment
Please, Sign In to add comment