Submission #520376

#TimeUsernameProblemLanguageResultExecution timeMemory
520376Alex_tz307Lampice (COCI21_lampice)C++17
50 / 50
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; void testCase() { int n, k; cin >> n >> k; vector<int> a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { for (int j = i; j <= n; ++j) { if ((j - i + 1) % k == 0) { vector<int> pattern, v; bool ok = true; for (int p = i; p <= j && ok; ++p) { v.emplace_back(a[p]); if ((int)v.size() == (j - i + 1) / k) { if (pattern.empty()) { pattern = v; } else { if (v != pattern) { ok = false; } } v.clear(); } } if (ok) { cout << pattern.size() << '\n'; for (int x : pattern) { cout << x << ' '; } cout << '\n'; return; } } } } cout << "-1\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tests = 1; for (int tc = 0; tc < tests; ++tc) { testCase(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...