結果

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main() {
	string s, newstr;

	cin >> s;
	int n = s.size();
	newstr = s;
	set<string> words;

	for (int i = (1 << (n - 1)) - 1; i >= 0; i--) {
		int front = 0;
		int rear = n - 1;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				newstr[j] = s[front];
				front++;
			} else {
				newstr[j] = s[rear];
				rear--;
			}
		}
		newstr[n - 1] = s[front];
		words.insert(newstr);
	}
	cout << words.size() << endl;
	return 0;
}
0