結果
| 問題 | No.52 よくある文字列の問題 | 
| コンテスト | |
| ユーザー |  beet | 
| 提出日時 | 2018-11-12 17:46:27 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 816 bytes | 
| コンパイル時間 | 1,919 ms | 
| コンパイル使用メモリ | 207,228 KB | 
| 最終ジャッジ日時 | 2025-01-06 16:33:13 | 
| ジャッジサーバーID (参考情報) | judge4 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  using D = deque<char>;
  D x(s.begin(),s.end());
  D y;
  set<D> ans;
  function<void()> dfs=
    [&](){
      if(x.empty()){
        ans.emplace(y);
        return;
      }
      {
        char c=x.front();
        x.pop_front();
        y.push_back(c);
        dfs();
        x.push_front(c);
        y.pop_back();
      }
      {
        char c=x.back();
        x.pop_back();
        y.push_back(c);
        dfs();
        x.push_back(c);
        y.pop_back();
      }
    };
  
  dfs();
  cout<<ans.size()<<endl;
  return 0;
}
            
            
            
        