結果

問題 No.197 手品
ユーザー nikollson
提出日時 2015-04-28 23:38:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 646 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 74,840 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-27 07:15:52
合計ジャッジ時間 1,798 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back


void saiki(set<string>& visit, string a, int d, int n){
	
	if(visit.find(a)!=visit.end())return;
	visit.insert(a);
	
	if(d>=n)return;
	
	rep(i,2){
		swap(a[i],a[i+1]);
		saiki(visit, a, d+1, n);
		swap(a[i],a[i+1]);
	}
}

int main(){
	string a,b;
	int n;
	cin>>a>>n>>b;
	
	set<string> A;
	saiki(A, a,0,min(20,n));
	
	if(A.find(b)==A.end()){
		puts("SUCCESS");
	}else{
		puts("FAILURE");
	}
}
0