Submission #588432

#TimeUsernameProblemLanguageResultExecution timeMemory
588432MilosMilutinovicLampice (COCI21_lampice)C++14
50 / 50
1 ms328 KiB
/** * author: wxhtzdy * created: 03.07.2022 11:20:17 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int L = 0, R = -2; for (int i = 0; i < n; i++) { for (int j = i + k - 1; j < n; j += k) { int len = (j - i + 1) / k; if (len <= R - L) { continue; } bool ok = true; for (int p = i; p <= j; p++) { ok = (ok & (a[p] == a[i + (p - i) % len])); } if (ok) { L = i; R = i + (j - i) / k; } } } cout << R - L + 1 << '\n'; for (int i = L; i <= R; i++) { cout << a[i] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...