제출 #1330283

#제출 시각아이디문제언어결과실행 시간메모리
1330283secondaccountmaybeLampice (COCI21_lampice)C++20
50 / 50
1 ms344 KiB
#include<bits/stdc++.h>
//designed by marss
#define ll long long
#define ss string
using namespace std;
void f()
{
	ll n,k;
	cin>>n>>k;
	vector<ll>a(n);
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(ll i=0;i<n;i++)
	{
		for(ll p=1;p*k<=n-i;p++)
		{
			bool ok=true;
			for(ll j=i;j<i+p*k&&ok;j++)
			{
				if(a[j]!=a[i+(j-i)%p])
				{
				  ok=false;
				}
			}
			if(ok)
			{
				cout<<p<<endl;
				for(ll j=i;j<i+p;j++)
				{
					cout<<a[j];
					if(j<i+p-1)
					{
					  cout<<" ";
					}
				}
				cout<<endl;
				return;
			}
		}
	}
	cout<<-1<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t=1;
	while(t--)
	{
		f();
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...