Submission #1690599


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("%.8f %.8f\n", X, Y);
}

Submission Info

Submission Time
Task E - CARtesian Coodinate
User lijingze8
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1556 Byte
Status WA
Exec Time 689 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 0 / 800
Status
AC × 2
WA × 1
AC × 11
WA × 24
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 WA 688 ms 1408 KB
02.txt AC 688 ms 1408 KB
03.txt WA 685 ms 1280 KB
04.txt WA 685 ms 1408 KB
05.txt WA 686 ms 1280 KB
06.txt WA 686 ms 1408 KB
07.txt WA 686 ms 1280 KB
08.txt WA 687 ms 1408 KB
09.txt WA 687 ms 1280 KB
10.txt WA 687 ms 1408 KB
11.txt WA 685 ms 1280 KB
12.txt WA 686 ms 1280 KB
13.txt WA 687 ms 1280 KB
14.txt WA 688 ms 1408 KB
15.txt WA 687 ms 1408 KB
16.txt WA 688 ms 1280 KB
17.txt WA 687 ms 1408 KB
18.txt WA 687 ms 1280 KB
19.txt AC 687 ms 1408 KB
20.txt WA 686 ms 1280 KB
21.txt AC 569 ms 1408 KB
22.txt AC 569 ms 1408 KB
23.txt WA 689 ms 1408 KB
24.txt WA 689 ms 1280 KB
25.txt WA 688 ms 1408 KB
26.txt WA 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 WA 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 WA 1 ms 256 KB