Submission #516294

#TimeUsernameProblemLanguageResultExecution timeMemory
516294penguinhackerLampice (COCI21_lampice)C++14
50 / 50
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=50; int n, k, a[mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i=0; i<n; ++i) cin >> a[i]; for (int i=0; i<n; ++i) for (int j=i; j<n; ++j) { if ((j-i+1)%k!=0) continue; int len=(j-i+1)/k; bool ok=1; for (int k=i; k<=j; ++k) ok&=a[k]==a[(k-i)%len+i]; if (ok) { cout << len << "\n"; for (int k=0; k<len; ++k) cout << a[i+k] << " "; return 0; } } cout << -1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...