結果

問題 No.52 よくある文字列の問題
ユーザー kroton
提出日時 2014-10-31 06:28:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 65,736 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 05:17:55
合計ジャッジ時間 1,108 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
using namespace std;

string S;
set<string> all;

void dfs(int L, int R, string acc){
    if(L > R){
        all.insert(acc);
        return;
    }
    
    dfs(L + 1, R, acc + S[L]);
    dfs(L, R - 1, acc + S[R]);
}

int main(){
    cin >> S;
    
    dfs(0, (int)S.size() - 1, "");
    cout << all.size() << endl;
    
    return 0;
}
0