結果

問題 No.52 よくある文字列の問題
ユーザー msm1993
提出日時 2020-05-15 15:04:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 541 bytes
コンパイル時間 1,438 ms
コンパイル使用メモリ 173,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 00:48:50
合計ジャッジ時間 1,934 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;

    set<string> st;
    for (int bit = 0; bit < (1 << S.size()); bit++) {
        string s = S;
        string ret;
        for (int i = 0; i < S.size(); i++) {
            if ((1 << i) & bit) {
                ret.push_back(s[0]);
                s.erase(s.begin());
            } else {
                ret.push_back(s.back());
                s.pop_back();
            }
        }
        st.insert(ret);
    }
    cout << (int)st.size() << endl;
}
0