이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define sz size
#define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll K = 32;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = (1e5 + 125);
void ma1n ()
{
ll n, k;
cin >> n >> k;
ll a[n + 7];
for (ll i = 1; i <= n; i++)
{
cin >> a[i];
}
for (ll sze = 1; (sze * k) <= n; sze++)
{
for (ll l = 1, r = sze * k; r <= n; r++, l++)
{
ll ok = 0;
for (ll ist = 1; ist < k; ist++)
{
for (ll i = (ist - 1) * sze + 1; i <= ist * sze; i++)
{
if (a[l + i - 1] != a[sze + l + i - 1])
{
ok = 1;
break;
}
}
if (ok)
{
break;
}
}
if (!ok)
{
cout << sze << "\n";
for (ll i = l; i <= l + sze - 1; i++)
{
cout << a[i] << " ";
}
return;
}
}
}
cout << -1 << "\n";
}
int main ()
{
Junanna;
ll t = 1;
while (t--)
{
ma1n ();
}
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... |