Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- #define int ll
- #define fi first
- #define se second
- #define pb push_back
- #define pf push_front
- #define ppb pop_back
- #define ppf pop_front
- #define INF (ll)1e18
- const int NMAX=1e2;
- int a[NMAX+500];
- signed main(){
- ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- int n;
- cin>>n;
- for(int i=1;i<=n;i++)cin>>a[i];
- for(int i=n;i>=1;i--){
- //суфікс-паліндром довжини i
- bool ok=1;
- for(int ii=n-i+1;ii<=n;ii++)if(a[ii]!=a[n-(ii-(n-i+1))])ok=0;
- if(ok){
- cout<<n-i<<"\n";
- for(int ii=(n-i);ii>=1;ii--){
- cout<<a[ii]<<" ";
- }cout<<"\n";
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement