結果

問題 No.3315 FPS Game
コンテスト
ユーザー 👑 ArcAki
提出日時 2025-03-02 01:15:58
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,715 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 477 ms
コンパイル使用メモリ 96,232 KB
実行使用メモリ 108,024 KB
最終ジャッジ日時 2026-07-10 10:32:50
合計ジャッジ時間 9,679 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:16: SyntaxWarning: invalid decimal literal
  self.parents = [-1for _ in range(num)]

ソースコード

diff #
raw source code

# 制約確認

from collections import deque, defaultdict as dd
from copy import deepcopy
from heapq import heappop, heappush, heappushpop, heapify
from random import randint, seed, shuffle, choice, choices, sample
from time import time

INF = 1 << 60
MOD = 998244353


class Unionfind:
    def __init__(self, num):
        self.num = num
        self.parents = [-1for _ in range(num)]

    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.find(x) > self.find(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 main():
    n, u, v = map(int, input().split())
    e = [list(map(int, input().split())) for _ in range(n-1)]
    assert 3 <= n <= 100000
    assert 1 <= u < v <= n-1
    uf = Unionfind(n)
    for u, v in e:
        assert 1 <= u < v <= n
        if uf.same(u-1, v-1):
            assert 1 < 0
        uf.union(u-1, v-1)


def no():
    print(n, s, t)
    for i in range(m - 1):
        print(i + 1, i + 2)
    for i in range(m, n):
        print(randint(2, m - 1), i + 1)


def nso():
    with open("output.txt", "w") as f:
        print(n, s, t, file=f)
        for i in range(m - 1):
            print(i + 1, i + 2, file=f)
        for i in range(m, n):
            print(randint(2, m - 1), i + 1, file=f)


if __name__ == "__main__":
    main()
0