제출 #1115676

#제출 시각아이디문제언어결과실행 시간메모리
1115676proshel_afgan_2015Lampice (COCI21_lampice)C++14
50 / 50
1 ms504 KiB
#include <bits/stdc++.h> # define int long long //# define double long double # define all(x) (x).begin(), (x).end() # define rall(x) (x).rbegin(), (x).rend() # define pi pair<int, int> # define f first # define s second using namespace std; void solve() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int l = 0; l < n; ++l) { for (int r = l; r < n; ++r) { int len = r - l + 1; if (len % k) continue; int c = len / k; bool b = true; for (int i = l; i <= r - c; ++i) { if (a[i] != a[i + c]) { b = false; break; } } if (b) { cout << c << "\n"; for (int i = l; i < l + c; ++i) { cout << a[i] << " "; } cout << "\n"; return; } } } cout << -1 << "\n"; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...