結果

問題 No.52 よくある文字列の問題
ユーザー kappybarkappybar
提出日時 2020-04-16 22:09:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 175,468 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 10:47:40
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const ll INF = 1e14;
const int MOD = 1000000007;
vector<string> ans;
string s;

void dfs(int l,int r,string now){
    if(l > r){
        ans.push_back(now);
    }
    else{
        dfs(l+1,r,now + s[l]);
        dfs(l,r-1,now + s[r]);
    }
}

int main(){
    cin >> s;
    dfs(0,s.size()-1,"");
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout << ans.size() << endl;
    return 0;
}
0