結果
問題 | No.1059 素敵な集合 |
ユーザー | mkawa2 |
提出日時 | 2021-05-26 22:52:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 968 ms / 2,000 ms |
コード長 | 1,237 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 189,256 KB |
最終ジャッジ日時 | 2024-04-23 16:16:53 |
合計ジャッジ時間 | 5,557 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
53,760 KB |
testcase_01 | AC | 968 ms
189,256 KB |
testcase_02 | AC | 134 ms
94,208 KB |
testcase_03 | AC | 40 ms
53,760 KB |
testcase_04 | AC | 41 ms
53,632 KB |
testcase_05 | AC | 41 ms
53,888 KB |
testcase_06 | AC | 115 ms
89,600 KB |
testcase_07 | AC | 115 ms
89,600 KB |
testcase_08 | AC | 125 ms
94,336 KB |
testcase_09 | AC | 87 ms
80,000 KB |
testcase_10 | AC | 164 ms
97,280 KB |
testcase_11 | AC | 114 ms
89,856 KB |
testcase_12 | AC | 95 ms
83,456 KB |
testcase_13 | AC | 173 ms
101,248 KB |
testcase_14 | AC | 68 ms
71,552 KB |
testcase_15 | AC | 281 ms
116,016 KB |
testcase_16 | AC | 125 ms
92,416 KB |
testcase_17 | AC | 118 ms
92,160 KB |
testcase_18 | AC | 92 ms
87,936 KB |
testcase_19 | AC | 721 ms
181,764 KB |
testcase_20 | AC | 710 ms
176,484 KB |
testcase_21 | AC | 262 ms
114,944 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] dij = [(0, 1), (1, 0), (1, 1), (1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from collections import defaultdict l, r = LI() to = defaultdict(list) for i in range(l, r+1): for j in range(i+i, r+1, i): to[i].append(j) to[j].append(i) def dfs(i): stack = [i] fin[i] = True while stack: i = stack.pop() for j in to[i]: if fin[j]: continue fin[j] = True stack.append(j) fin = [False]*(r+1) ans = 0 for i in range(l, r+1): if fin[i]: continue dfs(i) ans += 1 print(ans-1)