結果

問題 No.1694 ZerOne
ユーザー gew1fw
提出日時 2025-06-12 14:13:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 942 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 104,848 KB
最終ジャッジ日時 2025-06-12 14:14:15
合計ジャッジ時間 4,060 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_unique_strings(s):
    visited = set()
    from collections import deque
    q = deque()
    q.append(s)
    visited.add(s)
    n = len(s)

    while q:
        current = q.popleft()
        for i in range(n):
            for j in range(i+1, n+1):
                t = current[i:j]
                for k in range(j+1, n):
                    for l in range(k+1, n+1):
                        u = current[k:l]
                        if len(t) == 0 or len(u) == 0:
                            continue
                        if (t.count('0') == u.count('0') and
                            t.count('1') == u.count('1')):
                            new_s = current[:i] + u + current[j:k] + t + current[l:]
                            if new_s not in visited:
                                visited.add(new_s)
                                q.append(new_s)
    return len(visited)

s = input().strip()
print(count_unique_strings(s))
0