Submission #496515

#TimeUsernameProblemLanguageResultExecution timeMemory
496515kappaLampice (COCI21_lampice)C++14
50 / 50
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; int n, k, d[55]; int main(){ cin >> n >> k; for (int i = 0; i < n; i++) { cin >> d[i]; } for (int l = 0; l < n; l++) { for (int r = l; r < n; r++) { int temp = 1, len = r - l + 1; for (int i = 1; i < k && temp; i++) { for (int j = l; j <= r; j++) { if(j + i * len >= n || d[j + i * len] != d[j]){ temp = 0; break; } } } if(temp){ cout << len << "\n"; for (int i = l; i <= r; i++) { cout << d[i] << " "; } return 0; } } } cout << "-1"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...