結果
| 問題 |
No.517 壊れたアクセサリー
|
| コンテスト | |
| ユーザー |
Naoyk1212
|
| 提出日時 | 2017-05-28 22:21:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 730 bytes |
| コンパイル時間 | 1,713 ms |
| コンパイル使用メモリ | 165,608 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-09-21 15:35:02 |
| 合計ジャッジ時間 | 5,082 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 TLE * 1 -- * 5 |
ソースコード
#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;
}
Naoyk1212