結果
問題 | No.2462 七人カノン |
ユーザー | mattu34 |
提出日時 | 2023-09-08 21:39:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 336 ms / 2,000 ms |
コード長 | 2,074 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 104,812 KB |
最終ジャッジ日時 | 2024-06-26 14:32:26 |
合計ジャッジ時間 | 9,883 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
63,360 KB |
testcase_01 | AC | 52 ms
64,896 KB |
testcase_02 | AC | 49 ms
63,744 KB |
testcase_03 | AC | 68 ms
72,320 KB |
testcase_04 | AC | 63 ms
70,400 KB |
testcase_05 | AC | 64 ms
70,656 KB |
testcase_06 | AC | 65 ms
71,680 KB |
testcase_07 | AC | 61 ms
69,760 KB |
testcase_08 | AC | 67 ms
69,760 KB |
testcase_09 | AC | 61 ms
69,248 KB |
testcase_10 | AC | 68 ms
72,064 KB |
testcase_11 | AC | 68 ms
71,296 KB |
testcase_12 | AC | 69 ms
70,400 KB |
testcase_13 | AC | 273 ms
99,584 KB |
testcase_14 | AC | 301 ms
101,148 KB |
testcase_15 | AC | 270 ms
99,968 KB |
testcase_16 | AC | 290 ms
102,248 KB |
testcase_17 | AC | 293 ms
101,736 KB |
testcase_18 | AC | 88 ms
84,284 KB |
testcase_19 | AC | 86 ms
84,352 KB |
testcase_20 | AC | 325 ms
104,500 KB |
testcase_21 | AC | 328 ms
104,456 KB |
testcase_22 | AC | 309 ms
104,812 KB |
testcase_23 | AC | 323 ms
104,632 KB |
testcase_24 | AC | 228 ms
94,176 KB |
testcase_25 | AC | 336 ms
104,764 KB |
ソースコード
from collections import * import heapq import bisect import itertools class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): # 多用すると重い root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return "\n".join(f"{r}: {m}" for r, m in self.all_group_members().items()) dxdy = ((0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1)) INF = float("inf") MOD = 998244353 mod = 998244353 N, Q = map(int, input().split()) table = [0] * (10**5 + 2) query = [list(map(int, input().split())) for _ in range(Q)] p = [[] for _ in range(N)] for i, s, t in query: p[i - 1].append((s, t)) table[s + 1] += 1 table[t + 1] -= 1 for i in range(10**5 + 1): table[i + 1] += table[i] acc = [0] * (10**5 + 2) for i in range(10**5 + 1): acc[i + 1] = acc[i] if table[i] != 0: acc[i + 1] += 1 / table[i] ans = [0] * N # print(table[0:10]) # print(acc[0:10]) for i in range(N): for s, t in p[i]: ans[i] += acc[t + 1] - acc[s + 1] for a in ans: print(a)