Submission #895938

#TimeUsernameProblemLanguageResultExecution timeMemory
895938omsincoconutWish (LMIO19_noras)C++17
100 / 100
225 ms41920 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef long double ld; typedef pair<ld, ld> pld; #define mp(x, y) make_pair(x, y) const lli MAXN = 2e5+5; lli N; ld R; pld ab[MAXN], cd[MAXN], vel[MAXN]; vector<pair<ld, lli>> events; inline pld operator + (pld inp1, pld inp2) { return mp(inp1.first + inp2.first, inp1.second + inp2.second); } inline pld operator - (pld inp1, pld inp2) { return mp(inp1.first - inp2.first, inp1.second - inp2.second); } inline pld operator * (pld inp1, pld inp2) { return mp(inp1.first * inp2.first, inp1.second * inp2.second); } inline pld operator / (pld inp1, pld inp2) { return mp(inp1.first / inp2.first, inp1.second / inp2.second); } inline pld operator * (pld inp1, ld inp2) { return mp(inp1.first * inp2, inp1.second * inp2); } inline pld operator * (ld inp1, pld inp2) { return inp2*inp1; } inline pld operator / (pld inp1, ld inp2) { return mp(inp1.first / inp2, inp1.second / inp2); } inline pld operator / (ld inp1, pld inp2) { return inp2/inp1; } inline ld dist(pld inp) { return inp.first*inp.first + inp.second*inp.second; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N >> R; for (lli i = 0; i < N; i++) cin >> ab[i].first >> ab[i].second >> cd[i].first >> cd[i].second; for (lli i = 0; i < N; i++) vel[i] = cd[i] - ab[i]; for (lli i = 0; i < N; i++) { ld discrim = (2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)*(2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second) - 4*dist(vel[i])*(dist(ab[i])-R*R); if (discrim < 0) continue; ld lessroot = ((2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)-sqrtl(discrim))/(2*dist(vel[i])); ld moreroot = ((2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)+sqrtl(discrim))/(2*dist(vel[i])); lessroot *= -1; moreroot *= -1; swap(lessroot, moreroot); //cout << i << " " << lessroot << " " << moreroot << "\n"; if (moreroot < 0) continue; events.emplace_back(lessroot-(1e-10), 1); events.emplace_back(moreroot+(1e-10), -1); } sort(events.begin(), events.end()); lli ans = 0; lli ct = 0; lli time = 0; for (lli i = 0; i < events.size(); i++) { time = floor(events[i].first); ct += events[i].second; while (i+1 < events.size() && time == floor(events[i+1].first)) { ct += events[i+1].second; i++; } ans = max(ans, ct); } cout << ans; return 0; }

Compilation message (stderr)

noras.cpp: In function 'int main()':
noras.cpp:80:23: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<std::pair<long double, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for (lli i = 0; i < events.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
noras.cpp:83:20: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<std::pair<long double, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         while (i+1 < events.size() && time == floor(events[i+1].first)) {
      |                ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...