pypcdev

Untitled

Apr 16th, 2021
615
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef long double ld;
  5. #define int ll
  6. #define fi first
  7. #define se second
  8. #define pb push_back
  9. #define pf push_front
  10. #define ppb pop_back
  11. #define ppf pop_front
  12. #define INF (ll)1e18
  13.  
  14. const int NMAX=1e2;
  15. int a[NMAX+500];
  16.  
  17. signed main(){
  18.     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  19.     int n;
  20.     cin>>n;
  21.     for(int i=1;i<=n;i++)cin>>a[i];
  22.     for(int i=n;i>=1;i--){
  23.         //суфікс-паліндром довжини i
  24.         bool ok=1;
  25.         for(int ii=n-i+1;ii<=n;ii++)if(a[ii]!=a[n-(ii-(n-i+1))])ok=0;
  26.         if(ok){
  27.             cout<<n-i<<"\n";
  28.             for(int ii=(n-i);ii>=1;ii--){
  29.                 cout<<a[ii]<<" ";
  30.             }cout<<"\n";
  31.             return 0;
  32.         }
  33.     }
  34. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×