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>
#define REP(i,a,b) for (auto i = (a); i <= (b); ++i)
#define SIZE(x) int(x.size())
#define debug(x) cerr << #x << " is " << x << endl
#define el '\n'
using namespace std; using ll = long long;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, k; cin >> n >> k;
vector<int> a(n+1);
REP(i,1,n) cin >> a[i];
REP(i,1,n) REP(j,i,n) {
int x = j+1;
bool check = true;
REP(z,1,k-1) {
for (int cnt = 0; cnt <= j-i; ++cnt, ++x) {
if (x > n) {
check = false;
break;
}
if (a[x] != a[i+cnt]) {
check = false;
break;
}
}
if (not check) break;
}
if (check) {
cout << j-i+1 << el;
REP(y,i,j) {
cout << a[y] << ' ';
}
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... |