結果

問題 No.871 かえるのうた
ユーザー kawacchukawacchu
提出日時 2019-08-30 22:17:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,379 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,404 KB
最終ジャッジ日時 2024-05-01 18:27:52
合計ジャッジ時間 5,054 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
17,952 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 AC 37 ms
10,880 KB
testcase_03 AC 36 ms
10,880 KB
testcase_04 AC 33 ms
10,880 KB
testcase_05 AC 36 ms
10,880 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 33 ms
10,880 KB
testcase_08 AC 33 ms
11,264 KB
testcase_09 AC 34 ms
11,392 KB
testcase_10 AC 36 ms
11,008 KB
testcase_11 AC 34 ms
11,136 KB
testcase_12 AC 50 ms
14,080 KB
testcase_13 AC 38 ms
11,776 KB
testcase_14 AC 120 ms
27,528 KB
testcase_15 AC 121 ms
27,612 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from bisect import *
from collections import deque

class UnionFind:
    def __init__(self, num):
        self.rank = [0] * num
        self.par = [i for i in range(num)]
        self.n = num
 
    def find_root(self, node):
        if self.par[node] == node:
            return node
        else:
            self.par[node] = self.find_root(self.par[node])
            return self.par[node]
 
    def same_root(self, x, y):
        return self.find_root(x) == self.find_root(y)
 
    def union(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

N,K = map(int,input().split())
X = list(map(int,input().split()))
A = list(map(int,input().split()))

UF = UnionFind(N)
q = deque([K-1])

ok = [False]*N
ok[K-1] = True

while q :
    indn = q.popleft()
    x = X[indn]
    indl = bisect_left(X,x-A[indn])
    for j in range(indl,indn) :
        if ok[j] :
            continue
        ok[j] = True
        q.append(j)
    indr = bisect_right(X,x+A[indn])-1
    for j in range(indn+1,indr+1) :
        if ok[j] :
            continue
        ok[j] = True
        q.append(j)
print(ok.count(True))
0