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;
#define ll long long
#define ar array
const int mxN=50;
int n, k, a[mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i=0; i<n; ++i)
cin >> a[i];
for (int i=0; i<n; ++i)
for (int j=i; j<n; ++j) {
if ((j-i+1)%k!=0)
continue;
int len=(j-i+1)/k;
bool ok=1;
for (int k=i; k<=j; ++k)
ok&=a[k]==a[(k-i)%len+i];
if (ok) {
cout << len << "\n";
for (int k=0; k<len; ++k)
cout << a[i+k] << " ";
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... |