結果

問題 No.52 よくある文字列の問題
ユーザー ふっぴーふっぴー
提出日時 2017-04-16 23:07:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,149 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 104,164 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 04:08:08
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<ctime>
#include<cstdlib>
#include<numeric>
#include <typeinfo>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
const int inf=1e8;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define m 1000003

void solve(vector<string> *all,string *s1,string *s2){
	string s12,s22;
	s12=*s1;s22=*s2;
	if(s1->size()!=1){
		char last=s1->back();
		s1->pop_back();
		s2->push_back(last);
		solve(all,s1,s2);
		char first=s12.front();
		s12.erase(s12.begin());
		s22.push_back(first);
		solve(all,&s12,&s22);
	}else{
		*s2+=*s1;
		all->push_back(*s2);
	}
}
int main(){
	string s1;
	cin>>s1;
	string s2;
	vector<string> all;
	solve(&all,&s1,&s2);
	sort(all.begin(),all.end());
	string temp=all[0];
	int cnt=1;
	loop(i,1,all.size()){
		if(temp!=all[i]){
			cnt++;
			temp=all[i];
		}
	}
	cout<<cnt<<"\n";
}
0