結果
| 問題 | No.52 よくある文字列の問題 | 
| コンテスト | |
| ユーザー |  not_522 | 
| 提出日時 | 2015-07-19 17:12:51 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 524 bytes | 
| コンパイル時間 | 1,526 ms | 
| コンパイル使用メモリ | 175,020 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-22 05:21:56 | 
| 合計ジャッジ時間 | 2,035 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  queue<pair<string, string>> que;
  que.push(make_pair(s, ""));
  set<string> res;
  while (!que.empty()) {
    auto now = que.front();
    que.pop();
    if (now.first == "") {
      res.insert(now.second);
      continue;
    }
    que.push(make_pair(now.first.substr(1), now.second + now.first[0]));
    que.push(make_pair(now.first.substr(0, now.first.size() - 1), now.second + now.first.back()));
  }
  cout << res.size() << endl;
}
            
            
            
        