結果

問題 No.2293 無向辺 2-SAT
ユーザー 👑 p-adicp-adic
提出日時 2023-05-09 01:42:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 808 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 263,844 KB
最終ジャッジ日時 2024-05-04 06:42:56
合計ジャッジ時間 15,903 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
54,576 KB
testcase_01 AC 50 ms
82,844 KB
testcase_02 AC 33 ms
53,572 KB
testcase_03 AC 571 ms
119,476 KB
testcase_04 AC 3,793 ms
260,968 KB
testcase_05 AC 2,207 ms
263,844 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

I,J,R=input,int,range
X=I().split()
N,Q,P,p,w=J(X[0]),J(X[1]),998244353,[],[]
def r(i):
	m=p[i]
	while i!=m:
		p[i]=i=p[m]
		m=p[i]
	return i
n=0
def g(i,j):
	global n
	i,j=r(i),r(j)
	if i!=j:
		if w[i]==w[j]:w[j]+=1
		if w[i]<w[j]:p[i]=j
		else:p[j]=i
		n-=1
U,V,W,L=[0]*N,[0]*N,[0]*N,0
while Q>0:
	for l in R(L):V[W[l]]=0
	T,L,s=[],0,1
	A=T.append
	while Q>0:
		Q,X=Q-1,I().split()
		t=J(X[0])
		if t==3:
			A((t,))
			break
		else:
			u,v=J(X[1])-1,J(X[2])-1
			if V[u]==0:U[u],V[u],W[L],L=L,1,u,L+1
			if V[v]==0:U[v],V[v],W[L],L=L,1,v,L+1
			A((t,u,v))
	n=N*2
	p=[i for i in R(n)]
	w=[0]*n
	for l in T:
		if l[0]==3:print(pow(2,N,P))
		else:
			if s:
				u,v=U[l[1]],U[l[2]]
				t=u+L
				if l[0]==1:g(u,v),g(t,v+L)
				else:g(t,v),g(u,v+L)
				if p[r(u)]==p[r(t)]:s=0
			print(pow(2,n//2,P)if s else 0)
0