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;
const long long N = 2e5 + 5, mod = 1e9 + 7;
int n, k;
int main()
{
ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
cin >> n >> k;
vector<int> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
if ((j - i + 1) % k != 0)
continue;
int p = i, len = (j - i + 1) / k;
bool flag = 0;
for (int s = i; s <= j; s++)
{
if (arr[s] != arr[p])
flag = 1;
p++, len--;
if (len == 0)
len = (j - i + 1) / k, p = i;
}
if (!flag)
{
cout << len << "\n";
for (int s = i; s < i + len; s++)
cout << arr[s] << " ";
return 0;
}
}
}
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... |