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 n, k, d[55];
int main(){
cin >> n >> k;
for (int i = 0; i < n; i++)
{
cin >> d[i];
}
for (int l = 0; l < n; l++)
{
for (int r = l; r < n; r++)
{
int temp = 1, len = r - l + 1;
for (int i = 1; i < k && temp; i++)
{
for (int j = l; j <= r; j++)
{
if(j + i * len >= n || d[j + i * len] != d[j]){
temp = 0;
break;
}
}
}
if(temp){
cout << len << "\n";
for (int i = l; i <= r; i++)
{
cout << d[i] << " ";
}
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... |