fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. vector <string> a;
  5. string xoa(string a){
  6. int n = a.length();
  7. int i=0;
  8. while(i < n && a[i] == '0') i++;
  9. if(i == n) return "0";
  10. else return a.substr(i);
  11. }
  12. bool cmp(string &a, string &b){
  13. if(a.size() != b.size()) return a.size() < b.size();
  14. else return a < b;
  15. }
  16. int main(){
  17. int N; cin >> N;
  18. while(N--){
  19. string s; cin >> s;
  20. int n=s.length();
  21. string tmp="";
  22. for(int i=0;i<n;i++){
  23. if(isdigit(s[i])) tmp = tmp + s[i];
  24. else{
  25. if(tmp != "") a.push_back(tmp);
  26. tmp = "";
  27. }
  28. }
  29. if(tmp != "") a.push_back(tmp);
  30. }
  31. for(int i=0;i<a.size();i++){
  32. a[i] = xoa(a[i]);
  33. }
  34. sort(a.begin(),a.end(),cmp);
  35. for(int i=0;i<a.size();i++) cout << a[i] << endl;
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty