結果
問題 |
No.52 よくある文字列の問題
|
ユーザー |
|
提出日時 | 2019-03-08 13:09:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 991 ms |
コンパイル使用メモリ | 81,756 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 05:38:28 |
合計ジャッジ時間 | 1,498 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; string S; vector<string> tmp4; void dfs(string tmp1, string tmp2, string tmp3) { tmp1 += tmp2; if (tmp3.size() == 0) tmp4.push_back(tmp1); else if (tmp3.size() == 1) dfs(tmp1, tmp3.substr(0, 1), ""); else { dfs(tmp1, tmp3.substr(0, 1), tmp3.substr(1, tmp3.size() - 1)); dfs(tmp1, tmp3.substr(tmp3.size() - 1, 1), tmp3.substr(0, tmp3.size() - 1)); } } int main() { cin >> S; dfs("", S.substr(0, 1), S.substr(1, S.size() - 1)); dfs("", S.substr(S.size() - 1, 1), S.substr(0, S.size() - 1)); sort(tmp4.begin(), tmp4.end()); int ans = 1; for (int i = 1; i < tmp4.size(); ++i) { if (tmp4[i - 1] != tmp4[i]) ++ans; } cout << ans; }