結果

問題 No.52 よくある文字列の問題
ユーザー CleyLCleyL
提出日時 2020-03-01 19:54:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 22:22:50
合計ジャッジ時間 1,834 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string s;cin>>s;
    vector<string> ret;
    for(int bit = 0; (1<<s.size()) > bit; bit++){
        int nwl = 0;
        int nwr = s.size()-1;
        string t = "";
        for(int i = 0; s.size() > i; i++){
            if(bit & (1<<i)){
                t.push_back(s[nwl]);
                nwl++;
            }else{
                t.push_back(s[nwr]);
                nwr--;
            }
        }
        ret.push_back(t);
    }
    sort(ret.begin(),ret.end());
    ret.erase(unique(ret.begin(),ret.end()),ret.end());
    cout << ret.size() << endl;
}
0