Advertisement
Ahmed_Negm

C

Apr 14th, 2024
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define nl "\n"
  6.  
  7. void files(){
  8.     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
  9.     #ifndef ONLINE_JUDGE
  10.         freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  11.     #endif
  12. }
  13.  
  14. bool pali(string s){
  15.     string t = s;
  16.     reverse(t.begin(), t.end());
  17.     return s == t;
  18. }
  19.  
  20. void solve(){
  21.     int n; cin>>n;
  22.     vector<string> v(n);
  23.     for(int i=0; i<n; i++) cin>>v[i];
  24.     for(int i=0;i<n;i++){
  25.         for(int j=i+1;j<n;j++){
  26.             if(pali(v[i]+v[j]) || pali(v[j]+v[i])){
  27.                 cout<<"Yes\n";
  28.                 return;
  29.             }
  30.         }
  31.     }
  32.     cout<<"No\n";
  33. }
  34.  
  35. int main(){
  36.     files();
  37.     int t = 1;
  38.     // cin>>t;
  39.     while(t--) solve();
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement