답안 #770908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
770908 2023-07-02T06:13:56 Z dxz05 Wish (LMIO19_noras) C++17
0 / 100
2 ms 340 KB
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define MP make_pair
//#define endl '\n'

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 2005;

#define loop for (int it = 0; it < 70; it++)
#define ld double

void solve(){
    int n; ld R;
    cin >> n >> R;

    R *= R;

    ld lim = 2e4;

    vector<ld> st, en;

    for (int i = 1; i <= n; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        auto dist = [&](ld t) -> ld{
            ld x = c - a, y = d - b;
            x = x * t + a;
            y = y * t + b;
            return x * x + y * y;
        };

        ld t = -1;

        ld l = 1, r = lim;
        loop{
            ld m1 = l + (r - l) / 3;
            ld m2 = r - (r - l) / 3;

            ld f1 = dist(m1), f2 = dist(m2);

            if (f1 <= R || f2 <= R){
                t = (f1 <= R ? m1 : m2);
                break;
            }

            if (f1 < f2){
                r = m2;
            } else {
                l = m1;
            }

        }

        if (t == -1) continue;

        ld _st = t, _en = t;

        l = 1, r = t;
        loop{
            ld m = (l + r) / 2;
            if (dist(m) <= R){
                _st = min(_st, m);
                r = m;
            } else {
                l = m;
            }
        }

        l = t, r = lim;
        loop{
            ld m = (l + r) / 2;
            if (dist(m) <= R){
                _en = max(_en, m);
                l = m;
            } else {
                r = m;
            }
        }

        st.push_back(_st);
        en.push_back(_en);
    }

    sort(all(st));
    sort(all(en));

    int m = (int) st.size();

    int ans = 0;
    for (ld t : st){
        int i = upper_bound(all(st), t) - st.begin();
        int j = lower_bound(all(en), t) - en.begin() - 1;

        int cnt = m;
        cnt -= m - i;
        cnt -= j + 1;

        ans = max(ans, cnt);
    }

    for (ld t : en){
        int i = upper_bound(all(st), t) - st.begin();
        int j = lower_bound(all(en), t) - en.begin() - 1;

        int cnt = m;
        cnt -= m - i;
        cnt -= j + 1;

        ans = max(ans, cnt);
    }

    cout << ans << endl;

}

int main(){
    clock_t startTime = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int test_cases = 1;
//    cin >> test_cases;

    for (int test = 1; test <= test_cases; test++){
        //cout << (solve() ? "YES" : "NO") << endl;
        solve();
    }

#ifdef LOCAL
    cerr << "Time: " << int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl;
#endif

    return 0;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:130:13: warning: unused variable 'startTime' [-Wunused-variable]
  130 |     clock_t startTime = clock();
      |             ^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -