結果
| 問題 |
No.52 よくある文字列の問題
|
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-03-30 15:34:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 992 bytes |
| コンパイル時間 | 1,546 ms |
| コンパイル使用メモリ | 168,740 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 05:38:58 |
| 合計ジャッジ時間 | 2,258 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
// 1. 入力情報取得.
string S;
cin >> S;
// 2. 文字列長保存.
int l = S.size();
// 3. 文字列保存用.
map<string, int> m;
// 4. 探索.
for(int i = 0; i < (1 << l); i++){
// ex.
// i = 5 ならば, 101 で, 考える.
// -> 0: 先頭文字, 1: 末尾文字 と見做す.
string ts = S;
for(int j = 0; j < l; j++){
if((i >> j) & 1 == 1){
// 文字列の末尾を取得.
char b = ts.back();
// 取得した文字を, j番目に追加.
ts.insert(ts.begin() + j, b);
// 文字列の末尾削除.
ts.pop_back();
}
}
m[ts]++;
}
// for(auto &p : m) cout << p.first << ": "<< p.second << endl;
// 5. 出力.
int ans = m.size();
cout << ans << endl;
return 0;
}
@abcde