結果
問題 | No.1727 [Cherry 3rd Tune] Stray |
ユーザー | chocorusk |
提出日時 | 2021-09-13 22:31:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,106 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 52,608 KB |
最終ジャッジ日時 | 2024-04-16 13:36:22 |
合計ジャッジ時間 | 1,012 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
ソースコード
class UnionFind: def __init__(self, n): self.n=n self.par=[-1]*n def find(self, x): if self.par[x]<0: return x self.par[x]=self.find(self.par[x]) return self.par[x] def unite(self, x, y): x=self.find(x) y=self.find(y) if x==y: return False if self.par[x]<self.par[y]: x, y=y, x self.par[y]+=self.par[x] self.par[x]=y return True def same(self, x, y): return self.find(x)==self.find(y) def size(self, x): return -self.par[self.find(x)] n=int(input()) ans=(1<<(2*n)) uf=UnionFind(1<<(2*n)) for i in range(1<<(2*n)): x=0 y=0 for j in range(n): if (i&(1<<j))!=0: if j==n-1: x^=1 else: x^=(1<<(j+1)) y^=(1<<(j+n)) if (i&(1<<(j+n)))!=0: if j==0: x^=(1<<(2*n-1)) else: x^=(1<<(j-1+n)) y^=(1<<j) if uf.unite(i, x): ans-=1 if uf.unite(i, y): ans-=1 print(ans)