結果
問題 | No.2873 Kendall's Tau |
ユーザー | mkawa2 |
提出日時 | 2024-09-06 22:36:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,580 ms / 4,500 ms |
コード長 | 2,369 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,196 KB |
実行使用メモリ | 212,040 KB |
最終ジャッジ日時 | 2024-09-06 22:36:38 |
合計ジャッジ時間 | 25,944 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
54,296 KB |
testcase_01 | AC | 45 ms
56,064 KB |
testcase_02 | AC | 50 ms
54,916 KB |
testcase_03 | AC | 43 ms
55,040 KB |
testcase_04 | AC | 44 ms
55,788 KB |
testcase_05 | AC | 43 ms
54,876 KB |
testcase_06 | AC | 44 ms
54,384 KB |
testcase_07 | AC | 1,540 ms
193,096 KB |
testcase_08 | AC | 1,580 ms
209,356 KB |
testcase_09 | AC | 1,514 ms
194,104 KB |
testcase_10 | AC | 1,541 ms
212,040 KB |
testcase_11 | AC | 1,501 ms
193,488 KB |
testcase_12 | AC | 1,520 ms
211,516 KB |
testcase_13 | AC | 490 ms
112,168 KB |
testcase_14 | AC | 1,228 ms
184,272 KB |
testcase_15 | AC | 293 ms
98,664 KB |
testcase_16 | AC | 306 ms
97,712 KB |
testcase_17 | AC | 1,124 ms
164,020 KB |
testcase_18 | AC | 844 ms
144,596 KB |
testcase_19 | AC | 1,046 ms
162,052 KB |
testcase_20 | AC | 312 ms
97,980 KB |
testcase_21 | AC | 928 ms
149,560 KB |
testcase_22 | AC | 430 ms
109,196 KB |
testcase_23 | AC | 931 ms
149,920 KB |
testcase_24 | AC | 188 ms
85,756 KB |
testcase_25 | AC | 275 ms
96,848 KB |
testcase_26 | AC | 1,140 ms
165,788 KB |
testcase_27 | AC | 691 ms
134,664 KB |
testcase_28 | AC | 1,260 ms
179,656 KB |
testcase_29 | AC | 1,351 ms
195,508 KB |
testcase_30 | AC | 248 ms
92,640 KB |
testcase_31 | AC | 417 ms
106,104 KB |
testcase_32 | AC | 882 ms
147,148 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 class BitSum: def __init__(self, n): self._n = n+1 self._table = [0]*self._n self._origin = [0]*n def __getitem__(self, item): return self._origin[item] def __setitem__(self, index, value): self.add(index, value-self._origin[index]) self._origin[index] = value def add(self, i, x): if x == 0: return self._origin[i] += x i += 1 while i < self._n: self._table[i] += x i += i & -i def sum(self, r): res = 0 while r > 0: res += self._table[r] r -= r & -r return res def sumlr(self, l, r): if l >= r: return 0 if l == 0: return self.sum(r) return self.sum(r)-self.sum(l) # return "min(i) of sum(a[0]..a[i])>=x" or "N" def bisect(self, x): idx = 0 d = 1 << (self._n-1).bit_length()-1 while d: if idx|d < self._n and self._table[idx|d] < x: idx |= d x -= self._table[idx] d >>= 1 return idx from collections import Counter n=II() xy=LLI(n) enc={a:i for i,a in enumerate(sorted(set(y for x,y in xy)))} xy=[[x,enc[y]] for x,y in xy] cx=Counter() cy=Counter() r=s=n*(n-1)//2 bit=BitSum(n) p=0 xy.sort(key=lambda x:(x[0],-x[1])) for x,y in xy: r-=cx[x] s-=cy[y] cx[x]+=1 cy[y]+=1 p+=bit.sum(y) bit.add(y,1) bit=BitSum(n) q=0 xy=[[x,n-1-y] for x,y in xy] xy.sort(key=lambda x:(x[0],-x[1])) for x,y in xy: q+=bit.sum(y) bit.add(y,1) # print(p,q,r,s) print((p-q)/(r*s)**0.5)