Submission #2635232
Source Code Expand
import sys import socket if socket.gethostname() in ['N551J', 'F551C']: sys.stdin = open('e1.in') def read_int_list(): return list(map(int, input().split())) def read_int(): return int(input()) def read_str_list(): return input().split() def read_str(): return input() def find_median(n, A, B, C): def slope(u): return -u[0] / u[1] lines = list(zip(A, B, C)) lines.sort(key=slope) inf = 10 ** 20 sa = -inf sb = inf n_steps = 100 n_inversions_max = (n - 1) * n // 2 for _ in range(n_steps): s = (sa + sb) / 2 y = [(-a * s + c) / b for a, b, c, in lines] y.insert(0, 0) p = list(range(1, n + 1)) p.sort(key=y.__getitem__, reverse=True) c = count_inversions(n, p) if c > n_inversions_max // 2: sb = s else: sa = s return s def count_inversions(n, p): """Count the number of inversions t is the implicit data structure s[j] is the sum over ] j - j & -j, j] """ res = 0 s = [0] * (n + 1) for k in range(n): # sum over 1 .. t[p[k]] c = 0 u = p[k] while u > 0: c += s[u] u -= u & -u # increment t[p[k]] u = p[k] while u <= n: s[u] += 1 u += u & -u res += k - c return res def count_inversions_slow_but_correct(n, p): """Count the number of inversions t is the implicit data structure s[j] is the sum over ] j - j & -j, j] """ res = 0 for i in range(n): for j in range(i+1, n): res += p[i] > p[j] return res def solve(): n = read_int() a, b, c = zip(*[read_int_list() for i in range(n)]) # find the median of x-coordinates x = find_median(n, a, b, c) y = find_median(n, b, a, c) return x, y def main(): res = solve() print(*res) if __name__ == '__main__': main()
Submission Info
Submission Time | |
---|---|
Task | E - CARtesian Coodinate |
User | Martial |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 2078 Byte |
Status | WA |
Exec Time | 5257 ms |
Memory | 21840 KB |
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | TLE | 5257 ms | 19780 KB |
02.txt | TLE | 5257 ms | 19756 KB |
03.txt | TLE | 5257 ms | 19796 KB |
04.txt | TLE | 5256 ms | 21840 KB |
05.txt | TLE | 5257 ms | 19768 KB |
06.txt | TLE | 5257 ms | 19788 KB |
07.txt | TLE | 5257 ms | 19792 KB |
08.txt | TLE | 5257 ms | 19780 KB |
09.txt | TLE | 5257 ms | 19784 KB |
10.txt | TLE | 5256 ms | 19780 KB |
11.txt | TLE | 5256 ms | 21836 KB |
12.txt | TLE | 5257 ms | 19784 KB |
13.txt | TLE | 5257 ms | 19792 KB |
14.txt | TLE | 5257 ms | 19772 KB |
15.txt | TLE | 5257 ms | 19776 KB |
16.txt | TLE | 5257 ms | 19776 KB |
17.txt | TLE | 5257 ms | 19780 KB |
18.txt | TLE | 5256 ms | 21816 KB |
19.txt | TLE | 5257 ms | 19776 KB |
20.txt | TLE | 5257 ms | 19780 KB |
21.txt | TLE | 5257 ms | 18532 KB |
22.txt | TLE | 5256 ms | 20580 KB |
23.txt | TLE | 5257 ms | 19020 KB |
24.txt | TLE | 5257 ms | 19004 KB |
25.txt | TLE | 5257 ms | 19000 KB |
26.txt | TLE | 5257 ms | 19008 KB |
27.txt | AC | 26 ms | 3572 KB |
28.txt | AC | 25 ms | 3572 KB |
29.txt | AC | 25 ms | 3572 KB |
30.txt | WA | 26 ms | 3572 KB |
31.txt | AC | 26 ms | 3572 KB |
32.txt | AC | 25 ms | 3572 KB |
s1.txt | AC | 26 ms | 3572 KB |
s2.txt | WA | 26 ms | 3572 KB |
s3.txt | AC | 26 ms | 3572 KB |