結果
問題 | No.52 よくある文字列の問題 |
ユーザー | cww |
提出日時 | 2017-03-04 01:19:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 1,622 ms |
コンパイル使用メモリ | 174,252 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 05:29:23 |
合計ジャッジ時間 | 2,150 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; set<string> st; void dfs( string S, string T ) { //基底部:Sが空になったら終わり if( S.empty() ) { //重複を排除 st.emplace( T ); return; } //再帰部: //S[ 1 ] - S[ S.size() - 1 ]までを次に渡す, Tに「先頭」文字列をくっつける dfs( S.substr( 1, S.size() - 1 ), T + S[ 0 ] ); //S[ 0 ] - S[ S.size() - 1 ]までを次に渡す, Tに「末尾」文字列をくっつける dfs( S.substr( 0, S.size() - 1 ), T + S[ S.size() - 1 ] ); } int main() { string S, T; cin >> S; dfs( S, T ); cout << st.size() << endl; return 0; }