fork(1) download
  1. #include <iostream>
  2. #include<string>
  3. #include<vector>
  4. #include<algorithm>
  5. #define pb push_back
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int x,y,t,n;
  11. string s,w;
  12. vector<string>v;
  13. cin>>t;
  14. while(t--)
  15. {
  16. w="";
  17. cin>>s>>n;
  18. for(x=0;x<s.length();x++)
  19. {
  20. for(y=s.length()-x;y>=1;y--)
  21. {
  22. w=s.substr(x,y);
  23. v.pb(w);
  24. }
  25. }
  26. sort(v.begin(),v.end());
  27. w="";
  28. for(x=0;x<v.size();x++)
  29. {
  30. w=w+v[x];
  31. }
  32. cout<<w[n-1]<<endl;
  33.  
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Runtime error #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Standard output is empty