結果

問題 No.52 よくある文字列の問題
ユーザー springrollspringroll
提出日時 2018-11-18 16:48:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 655 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 176,372 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 04:16:40
合計ジャッジ時間 2,426 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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


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

	int n = s.length();
	set<string> strs;
	list<char> chs;
	for (int i = 0; i < n; i++) {
		chs.push_back(s[i]);
	}

	for (int bit = 0; bit < (1 << n); bit++) {
		list<char> tmp_chs=chs;

		string str;
		for (int i = 0; i < n; i++) {
			if (bit&(1 << i)) {
				str.push_back(tmp_chs.back());
				tmp_chs.pop_back();
			}
			else {
				str.push_back(tmp_chs.front());
				tmp_chs.pop_front();
			}
		}
		//cout <<" "<< str << endl;
		strs.insert(str);
	}
	for (auto itr = strs.begin(); itr != strs.end(); itr++) {
		//cout << *itr << endl;
	}
	cout << strs.size() << endl;
}
0