Guest User

Untitled

a guest
Apr 6th, 2025
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define maxarray 100005
  4. #define int long long
  5. #define el "\n"
  6. #define vtmc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  7. #define snpos string::npos
  8.  
  9. bool comp(string s1, string s2) {
  10. return (s1.length() <= s2.length());
  11. }
  12.  
  13. bool endsWith(const string& full, const string& suffix) {
  14. if (suffix.size() > full.size()) return false;
  15. return full.compare(full.size() - suffix.size(), suffix.size(), suffix) == 0;
  16. }
  17.  
  18. void solve() {
  19. int n;
  20. cin>>n;
  21. vector<string> v(n);
  22. for(string& s : v) {
  23. cin>>s;
  24. }
  25. sort(v.begin(),v.end(),comp);
  26. for(int i=1; i<n; i++) {
  27. if(!endsWith(v[i],v[0])){
  28. cout<<"Not found";
  29. return;
  30. }
  31. }
  32. cout << v[0];
  33. }
  34. signed main() {
  35. vtmc
  36. int t=1;
  37. // cin>>t;
  38. while(t-->0) {
  39. solve();
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment