結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
めうめう🎒
|
| 提出日時 | 2016-03-27 20:50:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 813 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 83,008 KB |
| 実行使用メモリ | 6,656 KB |
| 最終ジャッジ日時 | 2024-12-23 00:37:05 |
| 合計ジャッジ時間 | 1,727 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)
char s[10];
string str;
map<string,bool> found;
bool used[10] = {};
int dfs(string str2,int how){
if(how == str.size()){
if(found.find(str2) == found.end()){
found[str2] = true;
return 1;
}
return 0;
}
int sum = 0;
for(int i = 0;i < str.size();i++){
if(used[i]) continue;
used[i] = true;
sum += dfs(str2 + s[i],how + 1);
used[i] = false;
}
return sum;
}
int main() {
cin >> str;
found[str] = true;
for(int i = 0;i < str.size();i++){
s[i] = str[i];
}
cout << dfs("",0) << endl;
return 0;
}
めうめう🎒