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()
{
int n,K;
cin>>n>>K;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
int c = 1;
int len = (j-i+1);
for(int k=j+1;k<n;k++){
if(a[k] != a[k-len])break;
if((k-j)%len == 0)c++;
}
if(c >= K){
cout<<len<<'\n';
for(int x=i;x<=j;x++)cout<<a[x]<<" ";
return 0;
}
}
}
cout<<-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |