結果

問題 No.517 壊れたアクセサリー
コンテスト
ユーザー Naoyk1212
提出日時 2017-05-28 22:21:52
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 730 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,023 ms
コンパイル使用メモリ 183,692 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-04-09 20:54:34
合計ジャッジ時間 7,715 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 2 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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