結果

問題 No.197 手品
ユーザー hotpepsi
提出日時 2015-11-12 23:51:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 67,796 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 03:43:36
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <set>

using namespace std;

typedef set<string> StrSet;

int main(int argc, char *argv[]) {
	string a, b;
	int N;
	cin >> a;
	cin >> N;
	cin >> b;

	if (N > 100) {
		N = (N % 6) + 6;
	}

	StrSet m;
	m.insert(a);
	for (int i = 0; i < N; ++i) {
		StrSet n;
		for (string s : m) {
			string c = s;
			c[0] = s[1], c[1] = s[0];
			n.insert(c);
			c[0] = s[0], c[1] = s[2], c[2] = s[1];
			n.insert(c);
		}
		m = n;
	}

	cout << (m.find(b) == m.end() ? "SUCCESS" : "FAILURE") << endl;

	return 0;
}
0