結果

問題 No.52 よくある文字列の問題
ユーザー magurogumamaguroguma
提出日時 2017-09-09 18:18:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 685 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 12,024 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-10-22 04:11:20
合計ジャッジ時間 1,135 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,064 KB
testcase_01 AC 28 ms
10,064 KB
testcase_02 AC 31 ms
10,068 KB
testcase_03 AC 29 ms
10,064 KB
testcase_04 AC 32 ms
10,112 KB
testcase_05 AC 31 ms
10,068 KB
testcase_06 AC 32 ms
10,104 KB
testcase_07 AC 30 ms
10,076 KB
testcase_08 AC 29 ms
10,068 KB
testcase_09 AC 29 ms
10,064 KB
testcase_10 AC 28 ms
10,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

S = input()

str_dict = {}

# 0b0 ~ 0b111....1(len(S)-1桁)までの数を考える,Sを構成する文字を0は左から,1は右から文字を取る
for i in range(2**(len(S)-1)):
    bit_str = bin(i)
    copy_S = list(S)
    new_S = ''
    j = -1
    while bit_str[j] != 'b':
        if bit_str[j] == '0':
            new_S += copy_S[0]
            del(copy_S[0])
        else:
            new_S += copy_S[-1]
            del(copy_S[-1])
        j -= 1
    # 残っている分はすべて左から取って連結する
    for k in range(len(copy_S)):
        new_S += copy_S[0]
        del(copy_S[0])
    str_dict[new_S] = 1

print(len(str_dict))
0