結果
問題 |
No.52 よくある文字列の問題
|
ユーザー |
|
提出日時 | 2023-05-02 08:50:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 1,093 ms |
コンパイル使用メモリ | 83,276 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 00:51:25 |
合計ジャッジ時間 | 1,713 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string S; cin >> S; vector<string> lst; for (int bit = 0; bit < (1 << ((int)S.size() - 1)); ++bit) { int idxl = 0; int idxr = (int)S.size() - 1; string s = ""; for (int i = 0; i < (int)S.size() - 1; ++i) { if (bit & (1 << i)) { s += S[idxl++]; } else { s += S[idxr--]; } } s += S[idxl]; lst.push_back(s); } sort(lst.begin(), lst.end()); lst.erase(unique(lst.begin(), lst.end()), lst.end()); cout << (int)lst.size() << endl; }