結果
| 問題 |
No.52 よくある文字列の問題
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2016-07-20 14:13:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 521 bytes |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 67,812 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 05:26:39 |
| 合計ジャッジ時間 | 1,061 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include <iostream>
#include <list>
#include <string>
#include<set>
std::set<std::string> sets;
void f(std::list<char>& ls,std::string str){
if(ls.empty()==true){
sets.insert(str);
}else{
char c=ls.front();
ls.pop_front();
f(ls,str+c);
ls.push_front(c);
c=ls.back();
ls.pop_back();
f(ls,str+c);
ls.push_back(c);
}
}
int main() {
std::string str;
std::cin>>str;
std::list<char> ls;
for(int i=0;i<str.size();i++){
ls.push_back(str[i]);
}
f(ls,"");
std::cout<<sets.size()<<"\n";
return 0;
}
horiesiniti