Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define maxarray 100005
- #define int long long
- #define el "\n"
- #define vtmc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define snpos string::npos
- bool comp(string s1, string s2) {
- return (s1.length() <= s2.length());
- }
- bool endsWith(const string& full, const string& suffix) {
- if (suffix.size() > full.size()) return false;
- return full.compare(full.size() - suffix.size(), suffix.size(), suffix) == 0;
- }
- void solve() {
- int n;
- cin>>n;
- vector<string> v(n);
- for(string& s : v) {
- cin>>s;
- }
- sort(v.begin(),v.end(),comp);
- for(int i=1; i<n; i++) {
- if(!endsWith(v[i],v[0])){
- cout<<"Not found";
- return;
- }
- }
- cout << v[0];
- }
- signed main() {
- vtmc
- int t=1;
- // cin>>t;
- while(t-->0) {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment