#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int &i : a) cin >> i;
for (int i = 1; i * k <= n; i++) {
for (int j = 0; j + i * k <= n; j++) {
int ok = 1;
for (int _ = 0; _ < i * k; _++) {
if (a[j + _] != a[j + _ % i]) {
ok = 0;
}
}
if (ok) {
cout << i << '\n';
for (int _ = 0; _ < i; _++) cout << a[j + _] << ' ';
return 0;
}
}
}
cout << -1;
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... |