結果
問題 | No.1577 織姫と彦星2 |
ユーザー | ansain |
提出日時 | 2021-06-29 20:14:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 1,554 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 90,164 KB |
最終ジャッジ日時 | 2024-06-25 22:40:11 |
合計ジャッジ時間 | 6,385 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
54,528 KB |
testcase_01 | AC | 41 ms
54,272 KB |
testcase_02 | AC | 42 ms
55,040 KB |
testcase_03 | AC | 40 ms
54,912 KB |
testcase_04 | AC | 46 ms
54,016 KB |
testcase_05 | AC | 48 ms
65,792 KB |
testcase_06 | AC | 44 ms
62,336 KB |
testcase_07 | AC | 122 ms
85,888 KB |
testcase_08 | AC | 70 ms
73,516 KB |
testcase_09 | AC | 131 ms
90,060 KB |
testcase_10 | AC | 60 ms
71,168 KB |
testcase_11 | AC | 54 ms
64,768 KB |
testcase_12 | AC | 85 ms
78,080 KB |
testcase_13 | AC | 54 ms
69,632 KB |
testcase_14 | AC | 93 ms
80,640 KB |
testcase_15 | AC | 66 ms
70,144 KB |
testcase_16 | AC | 121 ms
85,760 KB |
testcase_17 | AC | 78 ms
75,392 KB |
testcase_18 | AC | 46 ms
60,928 KB |
testcase_19 | AC | 104 ms
82,408 KB |
testcase_20 | AC | 95 ms
78,980 KB |
testcase_21 | AC | 120 ms
85,728 KB |
testcase_22 | AC | 110 ms
83,096 KB |
testcase_23 | AC | 74 ms
72,960 KB |
testcase_24 | AC | 105 ms
89,984 KB |
testcase_25 | AC | 63 ms
69,120 KB |
testcase_26 | AC | 72 ms
72,192 KB |
testcase_27 | AC | 71 ms
81,152 KB |
testcase_28 | AC | 90 ms
79,104 KB |
testcase_29 | AC | 66 ms
74,112 KB |
testcase_30 | AC | 72 ms
75,776 KB |
testcase_31 | AC | 101 ms
82,992 KB |
testcase_32 | AC | 50 ms
64,640 KB |
testcase_33 | AC | 48 ms
62,720 KB |
testcase_34 | AC | 66 ms
73,600 KB |
testcase_35 | AC | 103 ms
81,760 KB |
testcase_36 | AC | 102 ms
83,604 KB |
testcase_37 | AC | 132 ms
89,892 KB |
testcase_38 | AC | 131 ms
89,856 KB |
testcase_39 | AC | 73 ms
73,216 KB |
testcase_40 | AC | 69 ms
73,472 KB |
testcase_41 | AC | 88 ms
85,376 KB |
testcase_42 | AC | 66 ms
76,672 KB |
testcase_43 | AC | 67 ms
77,056 KB |
testcase_44 | AC | 50 ms
64,512 KB |
testcase_45 | AC | 59 ms
67,968 KB |
testcase_46 | AC | 55 ms
68,736 KB |
testcase_47 | AC | 68 ms
82,432 KB |
testcase_48 | AC | 60 ms
71,808 KB |
testcase_49 | AC | 78 ms
75,776 KB |
testcase_50 | AC | 66 ms
70,656 KB |
testcase_51 | AC | 50 ms
64,128 KB |
testcase_52 | AC | 98 ms
88,192 KB |
testcase_53 | AC | 110 ms
90,164 KB |
testcase_54 | AC | 67 ms
74,496 KB |
testcase_55 | AC | 95 ms
87,916 KB |
testcase_56 | AC | 66 ms
70,912 KB |
testcase_57 | AC | 62 ms
66,772 KB |
ソースコード
import sys from collections import defaultdict, Counter, deque from itertools import permutations, combinations, product, combinations_with_replacement, groupby, accumulate import operator from math import sqrt, gcd, factorial # from math import isqrt, prod,comb # python3.8用(notpypy) #from bisect import bisect_left,bisect_right #from functools import lru_cache,reduce from heapq import heappush, heappop, heapify, heappushpop, heapreplace #import numpy as np #import networkx as nx #from networkx.utils import UnionFind #from numba import njit, b1, i1, i4, i8, f8 #from scipy.sparse import csr_matrix #from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, NegativeCycleError # numba例 @njit(i1(i4[:], i8[:, :]),cache=True) 引数i4配列、i8 2次元配列,戻り値i1 def input(): return sys.stdin.readline().rstrip() def divceil(n, k): return 1+(n-1)//k # n/kの切り上げを返す def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no) def main(): n = int(input()) s, t = map(int, input().split()) A = list(map(int, input().split())) dist = {AA:-1 for AA in A} dist[s] = 0 dist[t] = -1 d=deque() d.append(s) while d: v = d.popleft() for ii in range(30): i = v ^ (2**ii) if i not in dist: continue if dist[i] != -1: continue dist[i] = dist[v] + 1 d.append(i) print(-1 if dist[t]==-1 else dist[t]-1) if __name__ == '__main__': main()