Submission #697457

#TimeUsernameProblemLanguageResultExecution timeMemory
697457delreyLampice (COCI21_lampice)C++14
50 / 50
1 ms300 KiB
#include <iostream> using namespace std; int n, k, a[50]; int main() { cin>>n>>k; for(int i = 0; i < n; i++) cin>>a[i]; for(int b = 0; b < n; b++) { for(int i = 1; b + i * k <= n; i++) { int patterns = 1; for(int j = 1; j < k; j++) { bool matches = true; for(int t = 0; t < i; t++) if(a[b + t] != a[b + j * i + t]) { matches = false; break; } if(!matches) break; patterns++; } if(patterns == k) { cout<<i<<endl; for(int t = 0; t < i; t++) cout<<a[b + t]<<" "; return 0; } } } cout<<-1<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...