# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647090 | Alma | Lampice (COCI21_lampice) | C++14 | 1 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
using ll = long long;
using ii = pair<int,int>;
const int INF = 1e9;
const ll LLINF = 1e18;
using vi = vector<int>;
using vvi = vector<vi>;
void setIO (string fileName) {
ios::sync_with_stdio(false);
cin.tie(NULL);
if (fileName != "std") {
freopen((fileName + ".in").c_str(), "r", stdin);
freopen((fileName + ".out").c_str(), "w", stdout);
}
}
int main() {
setIO("std");
int n, k;
cin >> n >> k;
vi lamp(n);
for (int& i: lamp) cin >> i;
for (int len = 1; len <= n; len++) {
for (int i = 0; i < n and i + len*k <= n; i++) {
bool pos = true;
for (int t = 0; t < k and pos; t++) {
for (int j = 0; j < len and pos; j++) {
if (lamp[i+j] != lamp[i + len*t + j]) pos = false;
}
}
if (pos) {
cout << len << '\n';
for (int j = 0; j < len; j++) {
cout << lamp[i+j] << ' ';
}
return 0;
}
}
}
cout << "-1\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |