結果

問題 No.517 壊れたアクセサリー
ユーザー Naoyk1212Naoyk1212
提出日時 2017-05-28 22:21:52
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 730 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 167,684 KB
実行使用メモリ 7,740 KB
最終ジャッジ日時 2023-10-21 14:20:13
合計ジャッジ時間 5,519 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 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 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;
	cin >> n;
	vector<string> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];

	int m;
	cin >> m;
	vector<string> b(m);
	for(int i = 0; i < m; i++)cin >> b[i];

	vector<int> tmp(n), tmp1(m);

	for(int i = 0; i < n; i++)tmp[i] = i;
	for(int i = 0; i < m; i++)tmp1[i] = i;
	string s, s1;
	
	vector<string> ans;
	do{
		s = "";
		for(int i = 0; i < n; i++)s += a[tmp[i]];	
		do{
			s1 = "";
			for(int j = 0; j < m; j++)s1 += b[tmp1[j]];

			if(s == s1)ans.push_back(s);
		}while(next_permutation(tmp1.begin(), tmp1.end()));
	}while(next_permutation(tmp.begin(), tmp.end()));

	if(ans.size() == 1)cout << ans[0] << endl;
	else cout << -1 << endl;
}
0