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 std::vector;
using std::array;
using std::pair;
using std::tuple;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, K;
std::cin >> N >> K;
vector<int> A(N);
for (auto& x : A) {
std::cin >> x;
}
for (int l = 0; l < N; ++l) {
for (int k = 1; l + k * K <= N; ++k) {
bool ok = true;
for (int i = 0; i < K; ++i) {
for (int j = 0; j < k; ++j) {
if (A[l + j] != A[l + i * k + j]) {
ok = false;
}
}
}
if (ok) {
std::cout << k << '\n';
for (int j = 0; j < k; ++j) {
std::cout << A[l + j] << " \n"[j + 1 == k];
}
return 0;
}
}
}
std::cout << -1 << '\n';
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... |