結果

問題 No.52 よくある文字列の問題
コンテスト
ユーザー ふーらくたる
提出日時 2016-08-08 20:01:44
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 473µs
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 374 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-09-02 05:14:38
合計ジャッジ時間 1,417 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

string s;

void construct(int f_idx, int r_idx, string str, set<string>& works) {
    if (f_idx > r_idx) {
        works.insert(str);
        return;
    }
    construct(f_idx + 1, r_idx, str + s[f_idx], works);
    construct(f_idx, r_idx - 1, str + s[r_idx], works);
}

int main() {
    cin >> s;

    set<string> works;
    construct(0, s.size() - 1, "", works);

    cout << works.size() << endl;

    return 0;
}
0