Advertisement
Saleh127

CF 988B

Jul 30th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool cmpr(string a,string c)
  4. {
  5. return a.size()<c.size();
  6. }
  7.  
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(0);
  11. cin.tie(0);cout.tie(0);
  12.  
  13. vector<string>a;
  14. int n,i,j,k,l;
  15. cin>>n;
  16. string s;
  17. for(i=0;i<n;i++)
  18. {
  19. cin>>s;
  20. a.push_back(s);
  21. }
  22. sort(a.begin(),a.end(),cmpr);
  23. for(i=0;i<n-1;i++)
  24. {
  25. if(a[i+1].find(a[i])==-1)
  26. {
  27. cout<<"NO"<<endl;
  28. return 0;
  29. }
  30. }
  31. cout<<"YES"<<endl;
  32. for(i=0;i<n;i++)
  33. {
  34. cout<<a[i]<<endl;
  35. }
  36.  
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement