답안 #799555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799555 2023-07-31T15:57:17 Z vjudge1 Wish (LMIO19_noras) C++17
0 / 100
2 ms 484 KB
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int a[200005], b[200005], c[200005], d[200005], x[200005];
int main() {
    int n, r, flag = 0;
    cin >> n >> r;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        if (b[i] != d[i]) {
            flag = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] == c[i]) {
            swap(a[i], b[i]);
            swap(c[i], d[i]);
        }
        if (b[i] == d[i]) {
            if (b[i] > r) continue;
            double h = sqrt(r * r - b[i] * b[i]);
            if (a[i] > h && c[i] > a[i]) continue;
            if (a[i] < -h && c[i] < a[i]) continue;
            if (a[i] < -h && c[i] > h) continue;
            if (a[i] <= -h) {
                double k = (-h - a[i]) / (c[i] - a[i]);
                int l = (int)k;
                if (l * (c[i] - a[i]) != -h - a[i]) l++;
                double kk = (h - a[i]) / (c[i] - a[i]);
                int ll = (int)kk;
                x[l]++;
                x[ll + 1]--;
            }
            else if (a[i] >= h) {
                double k = (a[i] - h) / (a[i] - c[i]);
                int l = (int)k;
                if (l * (a[i] - c[i]) != a[i] - h) l++;
                double kk = (a[i] + h) / (a[i] - c[i]);
                int ll = (int)kk;
                x[l]++;
                x[ll + 1]--;
            }
            else {
                if (c[i] > a[i]) {
                    double kk = (h - a[i]) / (c[i] - a[i]);
                    int ll = (int)kk;
                    x[0]++;
                    x[ll + 1]--;
                }
                else {
                    double k = (a[i] - h) / (a[i] - c[i]);
                    int l = (int)k;
                    x[0]++;
                    x[l + 1]--;
                }
            }
            continue;
        }
        double h = (double)(d[i] - b[i]) / (c[i] - a[i]), k = b[i] - h * a[i];
        double A = h * h + 1, B = h * k * 2, C = k * k - r * r;
        if (B * B < 4 * A * C) continue;
        double xa = (-B + sqrt(B * B - 4 * A * C)) / (A * 2), xb = (-B - sqrt(B * B - 4 * A * C)) / (A * 2);
        double xx = (a[i] - xa) / (a[i] - c[i]), xxa = (a[i] - xb) / (a[i] - c[i]);
        int l = (int)xx, ll = (int)xxa;
        if (l * (a[i] - c[i]) != (a[i] - xa) && a[i] > xa) l++;
        if (ll * (a[i] - c[i]) != (a[i] - xb) && a[i] < xxa) ll++;
        if (l < 0 || ll < 0) continue;
        x[l]++;
        x[ll + 1]--;
    }
    int c = x[0], ma = c;
    for (int i = 1; i <= 100000; i++) {
        c += x[i];
        ma = max(ma, c);
    }
    cout << ma;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:7:15: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
    7 |     int n, r, flag = 0;
      |               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 2 ms 484 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 2 ms 484 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 2 ms 484 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 2 ms 484 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 2 ms 484 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -