This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int x,k;cin>>x>>k;
int a[x+1],mx=-1e9,l=1,r=1;
for(int i=1;i<=x;i++)cin>>a[i];
for(int i=1;i<=x;i++){
for(int j=i;j<=x;j++){
int p=j-i+1;
for(int s=p-1;s>=1;s--){
if(p%s||p/s<k)continue;
bool f=1;
for(int z=i+s;z<=j;z++)
f&=(a[z]==a[z-s]);
if(f){
if(mx<s){
mx=s;l=i;r=i+s-1;
}
break;
}
}
}
}
if(mx==-1e9){
cout<<-1;
return 0;
}
cout<<mx<<"\n";
for(int i=l;i<=r;i++)cout<<a[i]<<" ";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |