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;
typedef long long ll;
#define endl '\n'
void solve(){
int n,k;
cin>>n>>k;
vector<int> v(n);
for(auto &i:v) cin>>i;
for(int l=0;l<n;l++){
for(int r=l+k-1;r<n;r++){
int sz = r - l + 1;
if(sz % k) continue;
int sz2 = sz / k;
for(int i=l;i<=r;i++){
if(v[i] != v[(i-l)%sz2 + l]) goto gt;
}
cout<<sz2<<endl;
for(int i=l;i<=l+sz2-1;i++) cout<<v[i]<<' ';
cout<<endl;
return;
gt:continue;
}
}
cout<<-1<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
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... |