結果
| 問題 |
No.826 連絡網
|
| コンテスト | |
| ユーザー |
ゆるく
|
| 提出日時 | 2019-05-05 04:15:25 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,062 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 35,328 KB |
| 最終ジャッジ日時 | 2024-06-23 18:58:09 |
| 合計ジャッジ時間 | 25,123 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 TLE * 4 |
ソースコード
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
def find(x):
if node[x] < 0:
return x
else:
node[x] = find(node[x])
return node[x]
def unite(x, y):
x = find(x)
y = find(y)
if x != y:
if rank[x] > rank[y]:
node[x] += node[y]
node[y] = x
else:
node[y] += node[x]
node[x] = y
if rank[x] == rank[y]:
rank[y] += 1
def is_same(x, y):
return find(x) == find(y)
def size(x):
return -node[find(x)]
n, p = map(int, input().split())
node = [-1 for i in range(n + 1)]
rank = [0 for _ in range(n + 1)]
used = [False for _ in range(n+1)]
for i in range(2,int(n // 2) + 1):
if used[i]:
continue
for j in range(i, n + 1, i):
if i + j > n:
break
used[i + j] = True
unite(i, i + j)
print(size(find(p)))
ゆるく