Submission #872486

#TimeUsernameProblemLanguageResultExecution timeMemory
872486HossamHero7Lampice (COCI21_lampice)C++14
50 / 50
1 ms500 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...