Submission #1689914
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class Val>
struct BinaryIndexedTree {
int n;
vector<Val> t;
BinaryIndexedTree() {}
BinaryIndexedTree(int _n) :n(_n + 1), t(_n + 1) {}
void add(int k, Val val) {
k++;
while (k < n) {
t[k] += val;
k += (k&-k);
}
}
void set(int k, Val val) {
add(k, -sum(k, k + 1));
add(k, val);
}
Val sum(int k) {
Val r = 0;
while (k > 0) {
r += t[k];
k -= (k&-k);
}
return r;
}
Val sum(int l, int r) {
return sum(r) - sum(l);
}
};
typedef BinaryIndexedTree<int> BIT;
bool cmp(pair<int, int> a, pair<int, int> b) {
return 1ll*a.first*b.second<1ll*b.first*a.second;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
vi A(N), B(N), C(N);
rep(i, N)cin >> A[i] >> B[i] >> C[i];
const int need = (N*(N - 1) / 2 + 1) / 2;
auto f = [&](vi a, vi b, vi c) {
vector<pii> di(N);
rep(i, N) {
if (b[i] < 0)a[i] *= -1, b[i] *= -1, c[i] *= -1;
di[i] = mp(-a[i], b[i]);
}
sort(all(di));
di.erase(unique(all(di)), di.end());
sort(all(di), cmp);
double lb = -1e16, ub = 1e16, x;
rep(ITER, 100) {
x = (lb + ub)*0.5;
BIT bit(N);
vector<pair<double, int> > ry(N);
rep(i, N) {
ry[i] = mp((-a[i]*x+c[i])/b[i], i);
}
sort(all(ry));
int cnt = 0;
rep(k, N) {
int ly, i;
i = ry[k].second;
ly = lower_bound(all(di), mp(-a[i], b[i]), cmp) - di.begin();
cnt += bit.sum(0, ly);
bit.add(ly, 1);
}
(cnt >= need ? ub : lb) = x;
}
return ub;
};
double x = f(A, B, C), y = f(B, A, C);
cout << fixed << setprecision(20) << x << ' ' << y << endl;
}
Submission Info
Submission Time |
|
Task |
E - CARtesian Coodinate |
User |
paruki |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
2629 Byte |
Status |
AC |
Exec Time |
1694 ms |
Memory |
2432 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
800 / 800 |
Status |
|
|
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 |
1670 ms |
2304 KB |
02.txt |
AC |
1666 ms |
2304 KB |
03.txt |
AC |
1687 ms |
2304 KB |
04.txt |
AC |
1679 ms |
2304 KB |
05.txt |
AC |
1684 ms |
2304 KB |
06.txt |
AC |
1676 ms |
2304 KB |
07.txt |
AC |
1694 ms |
2304 KB |
08.txt |
AC |
1654 ms |
2304 KB |
09.txt |
AC |
1668 ms |
2304 KB |
10.txt |
AC |
1655 ms |
2304 KB |
11.txt |
AC |
1651 ms |
2304 KB |
12.txt |
AC |
1651 ms |
2304 KB |
13.txt |
AC |
1642 ms |
2304 KB |
14.txt |
AC |
1643 ms |
2304 KB |
15.txt |
AC |
1637 ms |
2304 KB |
16.txt |
AC |
1629 ms |
2304 KB |
17.txt |
AC |
1640 ms |
2304 KB |
18.txt |
AC |
1655 ms |
2304 KB |
19.txt |
AC |
1650 ms |
2304 KB |
20.txt |
AC |
1654 ms |
2304 KB |
21.txt |
AC |
1337 ms |
2304 KB |
22.txt |
AC |
1325 ms |
2304 KB |
23.txt |
AC |
1692 ms |
2432 KB |
24.txt |
AC |
1654 ms |
2304 KB |
25.txt |
AC |
1657 ms |
2304 KB |
26.txt |
AC |
1653 ms |
2304 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 |
1 ms |
256 KB |