# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47155 | Kmcode | DEL13 (info1cup18_del13) | C++14 | 15 ms | 1512 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 MAX 100002
int n;
vector<int> v;
int q;
vector<pair<int, int> > vv;
bool ng;
vector<int> ope;
vector<int> v2;
void er() {
v2.clear();
int las = 0;
for (int i = 0; i < vv.size(); i++) {
int L = vv[i].first;
int R = vv[i].second;
int rest = R - L + 1;
if (rest < las) {
ng = true;
break;
}
int need = las;
if (rest > 2) {
if (rest % 2) {
}
else {
rest--;
need--;
R--;
}
}
int mid = (R + L) / 2;
int z = vv[i].second-vv[i].first+1;
while (rest-2>=need&&rest>=3) {
ope.push_back(mid);
R--;
L++;
rest -= 2;
z -= 2;
}
while (las--) {
ope.push_back(vv[i].first - 1);
z--;
}
las = z;
}
if (las) {
ng = true;
}
vv.clear();
}
int main() {
int t;
cin >> t;
while (t--) {
ope.clear();
ng = false;
scanf("%d%d", &n,&q);
v.clear();
v.push_back(0);
for (int i = 0; i < q; i++) {
int a;
scanf("%d", &a);
v.push_back(a);
}
v.push_back(n+1);
v.push_back(n + 2);
for (int i = 1; i < v.size(); i++) {
if (v[i] - v[i - 1] - 1 == 0) {
er();
continue;
}
vv.push_back(make_pair(v[i - 1] + 1, v[i] - 1));
}
if (ng) {
puts("-1");
}
else {
cout << ope.size() << endl;
bool out = false;
for (int el : ope) {
if (out) {
printf(" ");
}
out = true;
printf("%d", el);
}
puts("");
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |