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>
#ifndef DEBUG
#include "railroad.h"
#endif
using namespace std;
template<typename T>
using V = vector<T>;
using ll = long long;
using vi = V<int>;
using pi = pair<int,int>;
constexpr int INF = 1e9 + 7;
#define F0R(i, n) for (int i = 0; i < n;i++)
#define FOR(i, j , n) for (int i = j ;i < n;i++)
struct Seg {
Seg *left = nullptr, *right = nullptr;
int l, r, mid;
pi v;
Seg(int l, int r, vi &arr) : l(l) ,r(r), mid((l + r) / 2) {
if (r - l > 1) {
left = new Seg(l, mid, arr);
right = new Seg(mid, r, arr);
v = min(left->v, right->v);
} else
v = {arr[l], l};
}
pi q(int a, int b) {
if (b <= l || a >= r) return {INF,INF};
if (a<=l && b>= r) return v;
return min(left->q(a,b), right->q(a,b));
}
void update(int x, int u) {
if (r - l <= 1) {
v = {u,l};
return;
}
if (x < mid)
left->update(x,u);
else
right->update(x,u);
v = min(left->v, right->v);
}
};
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
Tree<pi> stats;
int get(int y) {
return stats.order_of_key({y, -1});
}
long long plan_roller_coaster(vector<int> a, vector<int> b) {
set<pi> arr;
F0R(i, a.size()) {
arr.insert({a[i], b[i]});
}
auto it = arr.lower_bound({0, 0});
while (it != arr.end()) {
int next = it->second;
arr.erase(it);
it = arr.lower_bound({next, -1});
}
return !arr.empty();
}
#if DEBUG
int main() {
int n;
assert(1 == scanf("%d", &n));
std::vector<int> s(n), t(n);
for (int i = 0; i < n; ++i)
assert(2 == scanf("%d%d", &s[i], &t[i]));
long long ans = plan_roller_coaster(s, t);
printf("%lld\n", ans);
return 0;
}
#endif
Compilation message (stderr)
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:15:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | #define F0R(i, n) for (int i = 0; i < n;i++)
......
63 | F0R(i, a.size()) {
| ~~~~~~~~~~~
railroad.cpp:63:5: note: in expansion of macro 'F0R'
63 | F0R(i, a.size()) {
| ^~~
# | 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... |