Submission #540750

#TimeUsernameProblemLanguageResultExecution timeMemory
540750AlperenTLampice (COCI21_lampice)C++17
50 / 50
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; const int N = 50 + 5; int n, k, arr[N]; bool check(int l, int l2, int cnt){ for(int i = 0; i < cnt; i++) if(arr[l + i] != arr[l2 + i]) return false; return true; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n >> k; for(int i = 1; i <= n; i++) cin >> arr[i]; for(int len = 1; len <= n; len++){ for(int i = 1; i <= n; i++){ int cnt = 0; for(int j = i; j <= n; j += len){ if(j + len - 1 > n) break; else{ if(check(i, j, len)) cnt++; else break; } } if(cnt >= k){ cout << len << "\n"; for(int j = i; j < i + len; j++) cout << arr[j] << " "; return 0; } } } cout << -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...