Submission #878947

#TimeUsernameProblemLanguageResultExecution timeMemory
878947Youssif_ElkadiLampice (COCI21_lampice)C++17
50 / 50
1 ms456 KiB
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, mod = 1e9 + 7; int n, k; int main() { ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL); cin >> n >> k; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if ((j - i + 1) % k != 0) continue; int p = i, len = (j - i + 1) / k; bool flag = 0; for (int s = i; s <= j; s++) { if (arr[s] != arr[p]) flag = 1; p++, len--; if (len == 0) len = (j - i + 1) / k, p = i; } if (!flag) { cout << len << "\n"; for (int s = i; s < i + len; s++) cout << arr[s] << " "; return 0; } } } cout << -1 << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...