#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX = 1010;
int n, k;
int a[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i){
cin >> a[i];
}
for (int i = 1; k * i <= n; ++i){
for (int st = 1, en = k * i; en <= n; ++st, ++en){
bool flag = true;
for (int lf = st; lf <= en; lf += i){
for (int j = 0; j < i; ++j){
if (a[st + j] != a[lf + j]){
flag = false;
break;
}
}
}
if (flag){
cout << i << '\n';
for (int j = 0; j < i; ++j){
cout << a[st + j] << ' ';
}
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... |