結果

問題 No.2462 七人カノン
ユーザー mattu34mattu34
提出日時 2023-09-08 21:39:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 2,074 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 105,740 KB
最終ジャッジ日時 2023-09-08 21:39:55
合計ジャッジ時間 12,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
79,012 KB
testcase_01 AC 105 ms
79,364 KB
testcase_02 AC 103 ms
79,032 KB
testcase_03 AC 125 ms
79,988 KB
testcase_04 AC 118 ms
79,948 KB
testcase_05 AC 125 ms
79,872 KB
testcase_06 AC 119 ms
79,924 KB
testcase_07 AC 118 ms
79,768 KB
testcase_08 AC 117 ms
79,872 KB
testcase_09 AC 116 ms
80,076 KB
testcase_10 AC 122 ms
79,824 KB
testcase_11 AC 122 ms
80,080 KB
testcase_12 AC 118 ms
79,968 KB
testcase_13 AC 360 ms
101,088 KB
testcase_14 AC 347 ms
102,108 KB
testcase_15 AC 357 ms
99,900 KB
testcase_16 AC 350 ms
102,892 KB
testcase_17 AC 366 ms
103,156 KB
testcase_18 AC 135 ms
85,960 KB
testcase_19 AC 134 ms
85,100 KB
testcase_20 AC 414 ms
105,576 KB
testcase_21 AC 386 ms
105,320 KB
testcase_22 AC 384 ms
105,740 KB
testcase_23 AC 385 ms
105,652 KB
testcase_24 AC 314 ms
96,196 KB
testcase_25 AC 383 ms
105,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0