This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: Haunted_Cpp
**/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int l, r, y;
cin >> l >> r >> y;
multiset<pair<double, int>> sweep;
auto get_intersection = [&](int x, double slope) {
double b = - slope * x;
return (y - b) / slope;
};
auto is_integer = [&](double cur) {
if (cur == l || cur == r) return false;
int tst = cur;
return cur == tst;
};
for (int i = 0; i < n; i++) {
int x, vi, hi;
cin >> x >> vi >> hi;
double slope = 1.0 * vi / hi;
sweep.insert({get_intersection(x, slope), 1});
sweep.insert({get_intersection(x, - slope), 0});
}
int how_many = 0;
sweep.insert({r, 1});
map<int, double> cnt;
double ant = l;
for (auto to : sweep) {
int hi = floor(to.first);
int lo = ceil(ant);
const int add = hi - lo + 1 - (is_integer(ant) && is_integer(to.first) ? 2 : 0);
cnt[how_many] += add;
if (to.second == 0) ++how_many;
if (to.second == 1) --how_many;
ant = to.first;
}
long long s = 0;
for (int i = 0; i <= n; i++) {
s += cnt[i];
cout << s << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |