結果
問題 | No.2948 move move rotti |
ユーザー | katonyonko |
提出日時 | 2024-10-25 23:36:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,996 ms / 4,000 ms |
コード長 | 2,701 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 138,112 KB |
最終ジャッジ日時 | 2024-10-25 23:37:08 |
合計ジャッジ時間 | 21,212 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
56,220 KB |
testcase_01 | AC | 47 ms
56,340 KB |
testcase_02 | AC | 44 ms
55,868 KB |
testcase_03 | AC | 842 ms
101,256 KB |
testcase_04 | AC | 356 ms
137,604 KB |
testcase_05 | AC | 57 ms
67,260 KB |
testcase_06 | AC | 65 ms
69,540 KB |
testcase_07 | AC | 534 ms
137,764 KB |
testcase_08 | AC | 1,979 ms
137,908 KB |
testcase_09 | AC | 1,996 ms
137,996 KB |
testcase_10 | AC | 48 ms
55,748 KB |
testcase_11 | AC | 52 ms
63,732 KB |
testcase_12 | AC | 107 ms
78,092 KB |
testcase_13 | AC | 361 ms
105,040 KB |
testcase_14 | AC | 240 ms
101,112 KB |
testcase_15 | AC | 294 ms
84,884 KB |
testcase_16 | AC | 1,509 ms
125,900 KB |
testcase_17 | AC | 823 ms
101,396 KB |
testcase_18 | AC | 1,463 ms
137,708 KB |
testcase_19 | AC | 1,091 ms
137,800 KB |
testcase_20 | AC | 1,105 ms
137,844 KB |
testcase_21 | AC | 1,897 ms
138,112 KB |
testcase_22 | AC | 808 ms
137,700 KB |
testcase_23 | AC | 1,712 ms
137,920 KB |
testcase_24 | AC | 689 ms
137,956 KB |
testcase_25 | AC | 970 ms
138,096 KB |
testcase_26 | AC | 88 ms
76,876 KB |
testcase_27 | AC | 45 ms
55,908 KB |
testcase_28 | AC | 95 ms
77,436 KB |
testcase_29 | AC | 45 ms
55,724 KB |
testcase_30 | AC | 85 ms
77,140 KB |
ソースコード
import io import sys from collections import defaultdict, deque, Counter from itertools import permutations, combinations, accumulate from heapq import heappush, heappop from bisect import bisect_right, bisect_left from math import gcd import math _INPUT = """\ 6 3 2 2 1 3 1 2 2 3 5 5 4 2 2 2 2 1 2 2 4 3 5 4 5 1 5 4 4 2 1 2 1 2 2 3 3 4 1 4 """ def Popcount(n): c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333) c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f) c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff) c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff) c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff) return c def input(): return sys.stdin.readline()[:-1] def solve(test): N,M,K=map(int, input().split()) X=list(map(lambda x:int(x)-1, input().split())) G=[[] for _ in range(N)] for _ in range(M): A,B=map(int, input().split()) G[A-1].append(B-1) G[B-1].append(A-1) C=[0]*K*(2**N)*N def idx(i,j,k): return i*(2**N)*N+j*N+k for i in range(K): C[idx(i,1<<X[i],X[i])]=1 for j in range(1<<N): for k in range(N): if j&(1<<k): for l in G[k]: # if i==0 and j==5 and k==2: print(i,j^(1<<k),l,k,C[idx(i,j,k)],C[idx(i,j^(1<<k),l)]) if j&(1<<l) and C[idx(i,j^(1<<k),l)]==1: C[idx(i,j,k)]=1 # for i in range(K): # print(C[i*(2**N)*N:(i+1)*(2**N)*N]) ans=[0]*K*(N+1)*N for i in range(K): for j in range(1<<N): for k in range(N): if C[idx(i,j,k)]==1: # print(i,j,k,i*(N+1)*N+Popcount(j)*N+k,Popcount(j),K*N**2) ans[i*(N+1)*N+Popcount(j)*N+k]=1 # for i in range(K): # print(*ans[i*(N+1)*N:(i+1)*(N+1)*N]) ans2='No' for i in range(N*(N+1)): j,k=divmod(i,N) if all(ans[l*(N+1)*N+j*N+k]==1 for l in range(K)): ans2='Yes' break print(ans2) def random_input(): from random import randint,shuffle N=randint(1,10) M=randint(1,N) A=list(range(1,M+1))+[randint(1,M) for _ in range(N-M)] shuffle(A) return (" ".join(map(str, [N,M]))+"\n"+" ".join(map(str, A))+"\n")*3 def simple_solve(): return [] def main(test): if test==0: solve(0) elif test==1: sys.stdin = io.StringIO(_INPUT) case_no=int(input()) for _ in range(case_no): solve(0) else: for i in range(1000): sys.stdin = io.StringIO(random_input()) x=solve(1) y=simple_solve() if x!=y: print(i,x,y) print(*[line for line in sys.stdin],sep='') break #0:提出用、1:与えられたテスト用、2:ストレステスト用 main(0)