# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413024 | ja_kingy | Dancing Elephants (IOI11_elephants) | C++14 | 2460 ms | 16244 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 "elephants.h"
#include <bits/stdc++.h>
using namespace std;
const int SQRT = 500, mxN = 150000;
int n, x[mxN+1], l, req[mxN], nx[mxN], blk[mxN], ucnt;
vector<int> blocks[SQRT];
void build_block(int b) {
int ne = blocks[b].size();
for (int i = blocks[b].size(); i--;) {
while (x[blocks[b][ne-1]] > x[blocks[b][i]] + l) ne--;
req[blocks[b][i]] = ne == blocks[b].size() ? 1 : req[blocks[b][ne]] + 1;
nx[blocks[b][i]] = ne == blocks[b].size() ? x[blocks[b][i]] + l + 1 : nx[blocks[b][ne]];
}
}
void rebuild() {
for (int i = 0; i < (n+SQRT-1)/SQRT; ++i) {
blocks[i].clear();
}
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int a, int b){return x[a] < x[b];});
int b = 0;
for (int i = 0; i < n; ++i) {
blocks[b].push_back(order[i]);
blk[order[i]] = b;
if (blocks[b].size() == SQRT || i == n-1) {
build_block(b);
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... |