#include <iostream>
#include <vector>
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 l = 1; l <= n / k; ++l) {
bool flag = true;
for (int i = 0; i < l; ++i) {
for (int j = 1; j < k; ++j) {
if (a[i] != a[j * l + i]) {
flag = false;
break;
}
}
if (!flag) break;
}
if (flag) {
cout << l << endl;
for (int i = 0; i < l; ++i) {
cout << a[i] << " ";
}
cout << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |