結果

問題 No.197 手品
ユーザー nikollson
提出日時 2015-04-28 23:33:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 07:13:14
合計ジャッジ時間 2,040 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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,B;
	saiki(A, a,0,min(10,n));
	saiki(B, a,0,10);
	
	if(A.find(b)==A.end()){
		puts("SUCCESS");
	}else{
		puts("FAILURE");
	}
}
0