# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
609709 | strange420 | Roller Coaster Railroad (IOI16_railroad) | C++14 | 444 ms | 28420 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 "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 500000
int fenwick[MAXN], n;
void fenwickPointUpdate(int i, int val) {
i++;
while (i <= n) {
fenwick[i] += val;
i += i & (-i);
}
}
void fenwickUpdate(int l, int r) {
fenwickPointUpdate(l, 1);
fenwickPointUpdate(r, -1);
}
int getSum(int x) {
int sum = 0;
while (x > 0) {
sum += fenwick[x];
x -= x & (-x);
}
return sum;
}
int fenwickQuery(int x) {
x--; return getSum(x) - getSum(x-1);
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n = (int) s.size();
vector<int> asd;
for (int x: s) asd.push_back(x);
for (int x: t) asd.push_back(x);
sort(asd.begin(), asd.end());
map<int,int> indexing;
for (int i=0; i<asd.size(); i++)
indexing[asd[i]] = i;
for (int i=0; i<n; i++) {
s[i] = indexing[s[i]];
t[i] = indexing[t[i]];
}
for (int i=0; i<n; i++) fenwickUpdate(s[i], t[i] + 1);
for (int i=0; i<2*n; i++)
if (fenwickQuery(i) > 0) return 1;
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... |