Submission #1690653


Source Code Expand

#include<bits/stdc++.h>
#define N 100000
using namespace std;
struct line {
    int A, B, C, n;
    double p;
} L[N];
int t[N], n;
 
bool cmpX(line a, line b) {
    double Ka = -1.0 * a.A / a.B;
    double Kb = -1.0 * b.A / b.B;
    return Ka < Kb;
}
bool cmp(line a, line b) {
    return a.p < b.p;
}
int lb(int x) {
    return x & (-x);
}
double calc(double x, int i) {
    return ((double)L[i].C - (double)L[i].A * x) / L[i].B;
}
void add(int x) {
    for(; x <= n; x += lb(x)) t[x]++;
}
int ask(int x) {
    int ret = 0;
    for(; x > 0; x -= lb(x)) ret += t[x];
    return ret;
}
 
int ch(double mid) {
    for(int i = 1; i <= n; i++) L[i].p = calc(mid, i);
    sort(L + 1, L + n + 1, cmp);
    for(int i = 1; i <= n; i++) t[i] = 0;
    int ret = 0;
    for(int i = 1; i <= n; i++) {
        ret += ask(L[i].n);
        add(L[i].n);
    }
    return ret;
}
 
double sol() {
    double l = -1e9, r = 1e9;
    for(int i = 1; i <= 80; i++) {
        double mid = (l + r) / 2;
        int tmp = ch(mid);
        if (tmp + tmp < n * (n - 1) / 2) l = mid;
        else r = mid;
    }
    return l;
}
 
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d%d%d", &L[i].A, &L[i].B, &L[i].C);
    sort(L + 1, L + n + 1, cmpX);
    for(int i = 1; i <= n; i++) L[i].n = i;
    double X = sol();
    for(int i = 1; i <= n; i++) swap(L[i].A, L[i].B);
    sort(L + 1, L + n + 1, cmpX);
    for(int i = 1; i <= n; i++) L[i].n = i;
    double Y = sol();
    printf("%.20f %.20f\n", X, Y);
}

Submission Info

Submission Time
Task E - CARtesian Coodinate
User lijingze8
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1562 Byte
Status AC
Exec Time 687 ms
Memory 1408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:58:75: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d%d%d", &L[i].A, &L[i].B, &L[i].C);
                                                                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 3
AC × 35
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 686 ms 1408 KB
02.txt AC 684 ms 1408 KB
03.txt AC 683 ms 1280 KB
04.txt AC 683 ms 1280 KB
05.txt AC 686 ms 1280 KB
06.txt AC 685 ms 1408 KB
07.txt AC 685 ms 1280 KB
08.txt AC 685 ms 1280 KB
09.txt AC 685 ms 1280 KB
10.txt AC 685 ms 1408 KB
11.txt AC 684 ms 1408 KB
12.txt AC 684 ms 1408 KB
13.txt AC 685 ms 1280 KB
14.txt AC 685 ms 1408 KB
15.txt AC 685 ms 1408 KB
16.txt AC 687 ms 1280 KB
17.txt AC 685 ms 1280 KB
18.txt AC 686 ms 1280 KB
19.txt AC 685 ms 1408 KB
20.txt AC 685 ms 1280 KB
21.txt AC 569 ms 1280 KB
22.txt AC 568 ms 1408 KB
23.txt AC 687 ms 1408 KB
24.txt AC 687 ms 1280 KB
25.txt AC 687 ms 1280 KB
26.txt AC 687 ms 1408 KB
27.txt AC 1 ms 256 KB
28.txt AC 1 ms 256 KB
29.txt AC 1 ms 256 KB
30.txt AC 1 ms 256 KB
31.txt AC 1 ms 256 KB
32.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 2 ms 256 KB