結果
問題 | No.2948 move move rotti |
ユーザー | hato336 |
提出日時 | 2024-10-25 21:39:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,366 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 181,392 KB |
最終ジャッジ日時 | 2024-10-25 21:39:40 |
合計ジャッジ時間 | 18,706 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 137 ms
88,996 KB |
testcase_01 | WA | - |
testcase_02 | AC | 135 ms
89,224 KB |
testcase_03 | WA | - |
testcase_04 | AC | 524 ms
179,036 KB |
testcase_05 | WA | - |
testcase_06 | AC | 154 ms
90,044 KB |
testcase_07 | AC | 633 ms
179,620 KB |
testcase_08 | AC | 1,386 ms
180,664 KB |
testcase_09 | WA | - |
testcase_10 | AC | 133 ms
89,052 KB |
testcase_11 | AC | 139 ms
89,500 KB |
testcase_12 | AC | 189 ms
91,948 KB |
testcase_13 | AC | 434 ms
131,996 KB |
testcase_14 | AC | 353 ms
124,764 KB |
testcase_15 | AC | 312 ms
102,232 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 989 ms
180,708 KB |
testcase_21 | AC | 1,354 ms
180,652 KB |
testcase_22 | AC | 765 ms
180,812 KB |
testcase_23 | AC | 1,183 ms
179,716 KB |
testcase_24 | AC | 767 ms
180,192 KB |
testcase_25 | AC | 904 ms
180,744 KB |
testcase_26 | AC | 160 ms
90,244 KB |
testcase_27 | AC | 139 ms
89,164 KB |
testcase_28 | AC | 177 ms
90,300 KB |
testcase_29 | AC | 135 ms
89,204 KB |
testcase_30 | WA | - |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #alist = list(map(int,input().split())) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n 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.parents[x] > self.parents[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 members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = collections.defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return ''.join(f'{r}: {m}' for r, m in self.all_group_members().items()) #alist = [] #s = input() n,m,k = map(int,input().split()) x = list(map(lambda x:int(x)-1,input().split())) edge = [[] for i in range(n)] for i in range(m): u,v = map(int,input().split()) u-=1 v-=1 edge[u].append(v) edge[v].append(u) ans = [[set() for i in range(n+1)] for j in range(n+1)] for y in x: dist = [[0 for i in range(n)] for j in range(1<<n)] dist[1<<y][y] = 1 for s in range(1<<n): for i in range(n): if(s >> i) & 1 == 0: continue for j in edge[i]: if(s >> j) & 1 == 1: continue dist[s | (1 << j)][j] |= dist[s][i] if dist[s][i] == 1: ans[i][s.bit_count()].add(y) for i in range(n+1): for j in range(n+1): if len(ans[i][j]) == len(x) : exit(print('Yes')) print('No')