Submission #528356

#TimeUsernameProblemLanguageResultExecution timeMemory
528356CSQ31Lampice (COCI21_lampice)C++17
50 / 50
1 ms296 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,K; cin>>n>>K; vector<int>a(n); for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++){ for(int j=i;j<n;j++){ int c = 1; int len = (j-i+1); for(int k=j+1;k<n;k++){ if(a[k] != a[k-len])break; if((k-j)%len == 0)c++; } if(c >= K){ cout<<len<<'\n'; for(int x=i;x<=j;x++)cout<<a[x]<<" "; return 0; } } } cout<<-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...