Submission #1088623

#TimeUsernameProblemLanguageResultExecution timeMemory
1088623toast12Lampice (COCI21_lampice)C++14
50 / 50
1 ms436 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> nums(n); for (int i = 0; i < n; i++) { cin >> nums[i]; } int ans_len = -1, ans_start = -1; bool found = false; for (int i = 0; i < n && !found; i++) { for (int j = i; j < n && !found; j++) { int len = j-i+1; bool valid = true; for (int l = 1; l < k && valid; l++) { for (int m = 0; m < len && valid; m++) { int idx = i + l*len + m; if (idx < n) { if (nums[i+m] != nums[idx]) { valid = false; break; } } else { valid = false; break; } } } if (valid) { ans_len = len; ans_start = i; found = true; break; } } } if (ans_len == -1) cout << -1 << '\n'; else { cout << ans_len << '\n'; for (int i = ans_start; i < ans_start+ans_len; i++) cout << nums[i] << ' '; cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...