답안 #487436

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487436 2021-11-15T13:29:41 Z idas Wish (LMIO19_noras) C++17
93 / 100
183 ms 15044 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sz(x) int((x).size())

using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int INF=1e9, MOD=1e9+7, mod=98244353;
const long long LINF=1e7;

void setIO()
{
    FAST_IO;
}

void setIO(string s)
{
    FAST_IO;
    freopen((s+".in").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

const int N=2e5+10;
ll n, R;
pair<ll, ll> ini[N], add[N];

ll sq(ll x){return x*x;}

pair<ll, ll> getPos(int in, ll t)
{
    return {ini[in].F+add[in].F*t, ini[in].S+add[in].S*t};
}

ll calcDist(pair<ll, ll> pos)
{
    if(abs(pos.F)>INF||abs(pos.S)>INF) return -1;
    return sq(pos.F)+sq(pos.S);
}

ll getLow(int in)
{
    //davai patikrini po to shita shuda
    ll l=-1, r=LINF;
    while(l<r-1){
        ll m1=(l+r)/2, m2=m1+1;
        pair<ll, ll> pos1=getPos(in, m1), pos2=getPos(in, m2);
        ll v1=calcDist(pos1), v2=calcDist(pos2);
        if(v1<0||v2<0){
            r=m1;
            continue;
        }
        if(v1<=v2) r=m1;
        else l=m1;
    }
    return l+1;
}

ll lbound(int in, ll x)
{
    ll l=0, r=x;
    while(l<r){
        ll m=(l+r)/2;
        pair<ll, ll> pos=getPos(in, m); ll dist=calcDist(pos);
        if(dist<0){
            r=m;
            continue;
        }
        if(dist>R*R) l=m+1;
        else r=m;
    }
    return l;
}

ll rbound(int in, ll x)
{
    ll l=x, r=LINF;
    while(l<r){
        ll m=(l+r+1)/2;
        pair<ll, ll> pos=getPos(in, m); ll dist=calcDist(pos);
        if(dist<0){
            r=m-1;
            continue;
        }
        if(dist>R*R) r=m-1;
        else l=m;
    }
    return l;
}

int main()
{
    setIO();
    cin >> n >> R;
    ll now=0;
    FOR(i, 0, n)
    {
        ll aa, bb, cc, dd;
        cin >> aa >> bb >> cc >> dd;
        ini[i]={aa, bb}; add[i]={cc-aa, dd-bb};
    }

    vector<pair<ll, int>> inf;
    FOR(i, 0, n)
    {
        ll low=getLow(i);
        pair<ll, ll> pos=getPos(i, low); ll dist=sq(pos.F)+sq(pos.S);
        if(dist>R*R) continue;
        int l=lbound(i, low), r=rbound(i, low);
        inf.PB({l, 1}); inf.PB({r+1, -1});
    }

    sort(inf.begin(), inf.end());

    ll ans=0;
    for(auto[x, y] : inf){
        now+=y;
        ans=max(ans, now);
    }

    cout << ans;
}

/*
TESTINGAS:
3 1
0 0 100000 0
0 0 0 0
0 0 0 0
*/

Compilation message

noras.cpp: In function 'void setIO(std::string)':
noras.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
noras.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 58 ms 7620 KB Output is correct
24 Correct 55 ms 7608 KB Output is correct
25 Correct 57 ms 7680 KB Output is correct
26 Correct 56 ms 7632 KB Output is correct
27 Correct 54 ms 5532 KB Output is correct
28 Correct 59 ms 7684 KB Output is correct
29 Correct 63 ms 7612 KB Output is correct
30 Correct 59 ms 7688 KB Output is correct
31 Correct 60 ms 7628 KB Output is correct
32 Correct 74 ms 7632 KB Output is correct
33 Correct 74 ms 7592 KB Output is correct
34 Correct 76 ms 7624 KB Output is correct
35 Correct 78 ms 7652 KB Output is correct
36 Correct 82 ms 7704 KB Output is correct
37 Correct 60 ms 5532 KB Output is correct
38 Correct 58 ms 5568 KB Output is correct
39 Correct 67 ms 5568 KB Output is correct
40 Correct 73 ms 5576 KB Output is correct
41 Correct 58 ms 5608 KB Output is correct
42 Correct 57 ms 5568 KB Output is correct
43 Correct 172 ms 14892 KB Output is correct
44 Correct 170 ms 14864 KB Output is correct
45 Correct 172 ms 14820 KB Output is correct
46 Correct 175 ms 14944 KB Output is correct
47 Correct 175 ms 14916 KB Output is correct
48 Correct 155 ms 14908 KB Output is correct
49 Correct 154 ms 14800 KB Output is correct
50 Correct 153 ms 14928 KB Output is correct
51 Correct 147 ms 14888 KB Output is correct
52 Correct 152 ms 14788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 58 ms 7620 KB Output is correct
24 Correct 55 ms 7608 KB Output is correct
25 Correct 57 ms 7680 KB Output is correct
26 Correct 56 ms 7632 KB Output is correct
27 Correct 54 ms 5532 KB Output is correct
28 Correct 59 ms 7684 KB Output is correct
29 Correct 63 ms 7612 KB Output is correct
30 Correct 59 ms 7688 KB Output is correct
31 Correct 60 ms 7628 KB Output is correct
32 Correct 74 ms 7632 KB Output is correct
33 Correct 74 ms 7592 KB Output is correct
34 Correct 76 ms 7624 KB Output is correct
35 Correct 78 ms 7652 KB Output is correct
36 Correct 82 ms 7704 KB Output is correct
37 Correct 60 ms 5532 KB Output is correct
38 Correct 58 ms 5568 KB Output is correct
39 Correct 67 ms 5568 KB Output is correct
40 Correct 73 ms 5576 KB Output is correct
41 Correct 58 ms 5608 KB Output is correct
42 Correct 57 ms 5568 KB Output is correct
43 Correct 172 ms 14892 KB Output is correct
44 Correct 170 ms 14864 KB Output is correct
45 Correct 172 ms 14820 KB Output is correct
46 Correct 175 ms 14944 KB Output is correct
47 Correct 175 ms 14916 KB Output is correct
48 Correct 155 ms 14908 KB Output is correct
49 Correct 154 ms 14800 KB Output is correct
50 Correct 153 ms 14928 KB Output is correct
51 Correct 147 ms 14888 KB Output is correct
52 Correct 152 ms 14788 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 61 ms 7612 KB Output is correct
60 Correct 56 ms 5568 KB Output is correct
61 Correct 56 ms 5512 KB Output is correct
62 Correct 60 ms 5532 KB Output is correct
63 Correct 64 ms 5612 KB Output is correct
64 Correct 61 ms 5520 KB Output is correct
65 Correct 76 ms 5608 KB Output is correct
66 Correct 67 ms 5596 KB Output is correct
67 Correct 67 ms 5644 KB Output is correct
68 Correct 79 ms 7684 KB Output is correct
69 Correct 77 ms 7612 KB Output is correct
70 Correct 95 ms 7644 KB Output is correct
71 Correct 82 ms 7708 KB Output is correct
72 Correct 78 ms 7652 KB Output is correct
73 Correct 56 ms 5568 KB Output is correct
74 Correct 59 ms 7588 KB Output is correct
75 Correct 61 ms 7664 KB Output is correct
76 Correct 58 ms 5544 KB Output is correct
77 Correct 164 ms 14836 KB Output is correct
78 Correct 183 ms 15044 KB Output is correct
79 Correct 161 ms 14800 KB Output is correct
80 Correct 160 ms 14804 KB Output is correct
81 Correct 158 ms 14820 KB Output is correct
82 Correct 159 ms 14896 KB Output is correct
83 Correct 159 ms 14944 KB Output is correct
84 Correct 153 ms 14828 KB Output is correct
85 Correct 150 ms 14820 KB Output is correct
86 Correct 159 ms 14904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 58 ms 7620 KB Output is correct
24 Correct 55 ms 7608 KB Output is correct
25 Correct 57 ms 7680 KB Output is correct
26 Correct 56 ms 7632 KB Output is correct
27 Correct 54 ms 5532 KB Output is correct
28 Correct 59 ms 7684 KB Output is correct
29 Correct 63 ms 7612 KB Output is correct
30 Correct 59 ms 7688 KB Output is correct
31 Correct 60 ms 7628 KB Output is correct
32 Correct 74 ms 7632 KB Output is correct
33 Correct 74 ms 7592 KB Output is correct
34 Correct 76 ms 7624 KB Output is correct
35 Correct 78 ms 7652 KB Output is correct
36 Correct 82 ms 7704 KB Output is correct
37 Correct 60 ms 5532 KB Output is correct
38 Correct 58 ms 5568 KB Output is correct
39 Correct 67 ms 5568 KB Output is correct
40 Correct 73 ms 5576 KB Output is correct
41 Correct 58 ms 5608 KB Output is correct
42 Correct 57 ms 5568 KB Output is correct
43 Correct 172 ms 14892 KB Output is correct
44 Correct 170 ms 14864 KB Output is correct
45 Correct 172 ms 14820 KB Output is correct
46 Correct 175 ms 14944 KB Output is correct
47 Correct 175 ms 14916 KB Output is correct
48 Correct 155 ms 14908 KB Output is correct
49 Correct 154 ms 14800 KB Output is correct
50 Correct 153 ms 14928 KB Output is correct
51 Correct 147 ms 14888 KB Output is correct
52 Correct 152 ms 14788 KB Output is correct
53 Correct 61 ms 7612 KB Output is correct
54 Correct 56 ms 5568 KB Output is correct
55 Correct 56 ms 5512 KB Output is correct
56 Correct 60 ms 5532 KB Output is correct
57 Correct 64 ms 5612 KB Output is correct
58 Correct 61 ms 5520 KB Output is correct
59 Correct 76 ms 5608 KB Output is correct
60 Correct 67 ms 5596 KB Output is correct
61 Correct 67 ms 5644 KB Output is correct
62 Correct 79 ms 7684 KB Output is correct
63 Correct 77 ms 7612 KB Output is correct
64 Correct 95 ms 7644 KB Output is correct
65 Correct 82 ms 7708 KB Output is correct
66 Correct 78 ms 7652 KB Output is correct
67 Correct 56 ms 5568 KB Output is correct
68 Correct 59 ms 7588 KB Output is correct
69 Correct 61 ms 7664 KB Output is correct
70 Correct 58 ms 5544 KB Output is correct
71 Correct 164 ms 14836 KB Output is correct
72 Correct 183 ms 15044 KB Output is correct
73 Correct 161 ms 14800 KB Output is correct
74 Correct 160 ms 14804 KB Output is correct
75 Correct 158 ms 14820 KB Output is correct
76 Correct 159 ms 14896 KB Output is correct
77 Correct 159 ms 14944 KB Output is correct
78 Correct 153 ms 14828 KB Output is correct
79 Correct 150 ms 14820 KB Output is correct
80 Correct 159 ms 14904 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 1 ms 332 KB Output is correct
84 Correct 1 ms 332 KB Output is correct
85 Correct 1 ms 332 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 77 ms 5620 KB Output is correct
88 Correct 76 ms 9204 KB Output is correct
89 Correct 76 ms 9156 KB Output is correct
90 Correct 74 ms 9192 KB Output is correct
91 Correct 92 ms 9188 KB Output is correct
92 Correct 65 ms 8096 KB Output is correct
93 Incorrect 69 ms 8136 KB Output isn't correct
94 Halted 0 ms 0 KB -