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 "light.h"
#include <bits/stdc++.h>
using namespace std;
long long n;
bool on[5005];
bool new_on[5005];
void prepare() {
n = 1;
on[1] = true;
}
pair<long long, vector<long long>> join(long long p) {
n += p;
int lst = -p;
for (int i = 1; i <= n; i++) {
if (on[i]) {
lst = i;
}
new_on[i] = (i - lst < p);
}
for (int i = 1; i <= n; i++) {
on[i] = new_on[i];
}
vector<long long> ids(1, n);
while (true) {
int i = ids.back();
int idx = -1;
int len = n - i + 1;
for (int j = max(1, i - len - 1); j < i; j++) {
if (on[j]) {
idx = j;
break;
}
}
if (idx == -1) {
break;
}
ids.push_back(idx);
}
ids.push_back(1);
for (int i = 1; i <= n; i++) {
on[i] = false;
}
for (int i : ids) {
on[i] = true;
}
sort(ids.begin(), ids.end());
ids.erase(unique(ids.begin(), ids.end()), ids.end());
return {p, ids};
}
pair<long long, vector<long long>> leave(long long p) {
n -= p;
int lst = -p;
for (int i = 1; i <= n; i++) {
if (on[i]) {
lst = i;
}
new_on[i] = (i - lst < p);
}
for (int i = 1; i <= n; i++) {
on[i] = new_on[i];
}
vector<long long> ids(1, n);
while (true) {
int i = ids.back();
int idx = -1;
int len = n - i + 1;
for (int j = max(1, i - len - 1); j < i; j++) {
if (on[j]) {
idx = j;
break;
}
}
if (idx == -1) {
break;
}
ids.push_back(idx);
}
ids.push_back(1);
for (int i = 1; i <= n; i++) {
on[i] = false;
}
for (int i : ids) {
on[i] = true;
}
sort(ids.begin(), ids.end());
ids.erase(unique(ids.begin(), ids.end()), ids.end());
return {p, ids};
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |