# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
708327 | tamyte | Wish (LMIO19_noras) | C++14 | 1 ms | 212 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 <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
if (sz(name)) {
freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
freopen((name + ".out").c_str(), "w", stdout);
}
}
/*----------------------------------*/
typedef long long ll;
struct star
{
long long x, y;
long long dx, dy;
} stars[(int)2e5 + 1];
long long max_t(int i, long long r) {
if (stars[i].dx == 0) {
return abs(r - stars[i].y) / abs(stars[i].dy);
} else if (stars[i].dy == 0) {
return abs(r - stars[i].x) / abs(stars[i].dx);
}
return max(abs(r - stars[i].x) / abs(stars[i].dx),
abs(r - stars[i].y) / abs(stars[i].dy));
}
int main() {
setIO("");
int n;
ll r;
cin >> n >> r;
for (int i = 0; i < n; ++i) {
cin >> stars[i].x >> stars[i].y >> stars[i].dx >> stars[i].dy;
stars[i].dy = stars[i].dy - stars[i].y;
stars[i].dx = stars[i].dx - stars[i].x;
// cout << stars[i].dx << " : " << stars[i].dy << "\n";
}
vector<long long> start, finish;
for (int i = 0; i < n; ++i) {
long long left = 0, right = max_t(i, r);
// cerr << left << " " << right << "\n";
while (left < right) {
long long mid = (left + right) / 2;
long long cx = stars[i].x + stars[i].dx * mid;
long long cy = stars[i].y + stars[i].dy * mid;
// cerr << cx << " " << cy << " : ";
if (cx * cx + cy * cy > r * r && (cx <= 0 || cy <= 0)) {
left = mid + 1;
} else if (cx * cx + cy * cy == r * r) {
left = mid;
break;
} else {
right = mid - 1;
}
// cerr << left << " " << right << "\n";
}
if ((stars[i].x + stars[i].dx * left) * (stars[i].x + stars[i].dx * left)
+ (stars[i].y + stars[i].dy * left) * (stars[i].y + stars[i].dy * left) <= r * r) start.push_back(left);
else continue;
// cerr << left << " -> ";
right = 1000000000000LL;
while (left < right) {
long long mid = (left + right) / 2;
long long cx = stars[i].x + stars[i].dx * mid;
long long cy = stars[i].y + stars[i].dy * mid;
// cerr << cx << " " << cy << " - ";
// cerr << left << " " << right << "\n";
if (cx * cx + cy * cy > r * r) {
right = mid - 1;
} else {
left = mid + 1;
}
}
finish.push_back(left);
// cout << left << "\n";
}
sort(start.begin(), start.end());
sort(finish.begin(), finish.end());
int ii = 0, jj = 0;
int curr = 0, mx = 0;
while (ii < start.size()) {
for (; ii < start.size() && start[ii] <= finish[jj]; ++ii) curr++;
mx = max(curr, mx);
curr--;
jj++;
}
cout << mx;
}
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... |