結果

問題 No.1727 [Cherry 3rd Tune] Stray
ユーザー chocoruskchocorusk
提出日時 2021-09-14 20:38:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,239 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 52,864 KB
最終ジャッジ日時 2024-04-16 13:36:42
合計ジャッジ時間 1,066 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)):
    for j in range(n):
        v=0
        w=0
        for k in range(2*n):
            if (i&(1<<k))!=0:
                if k<n:
                    p=k+j
                    if p>=n:
                        p-=n
                    v^=(1<<p)
                    w^=(1<<(p+n))
                else:
                    p=(k-n)+n-j
                    if p>=n:
                        p-=n
                    v^=(1<<(p+n))
                    w^=(1<<p)
        if uf.unite(i, v):
            ans-=1
        if uf.unite(i, w):
            ans-=1
print(ans)
0