結果
問題 | No.52 よくある文字列の問題 |
ユーザー |
![]() |
提出日時 | 2018-06-26 19:27:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 868 ms |
コンパイル使用メモリ | 99,352 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 05:36:16 |
合計ジャッジ時間 | 1,319 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <iomanip> using namespace std; #define INF 1e9 #define PI acos(-1) typedef long long ll; string str; set<string> cnt; int dfs(int n, string x, string rest) { if (n == 0) { if (cnt.count(x) == 0) { cnt.insert(x); return 1; } else return 0; } int ans = 0; ans += dfs(n - 1, x + rest[0], rest.substr(1, n - 1)); ans += dfs(n - 1, x + rest[n - 1], rest.substr(0, n - 1)); return ans; } int main() { cin >> str; int n = str.size(); cout << dfs(n, "", str) << endl; return 0; }