dame-taikula
2024-01-22 19:37:20
发布于:广东
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
bool solve(array<string, 4> blocks){
string word;
cin >> word;
do{
bool ok = true;
for(int i = 0; i < word.size(); i++){
if(find(blocks[i].begin(), blocks[i].end(), word[i]) == blocks[i].end()){
ok = false;
}
}
if(ok){
return true;
}
}while(next_permutation(blocks.begin(), blocks.end()));
return false;
}
int main(){
int tc;
cin >> tc;
array<string, 4> blocks;
for(int i = 0; i < 4; i++){
cin >> blocks[i];
}
sort(blocks.begin(), blocks.end());
for(int i = 0; i < tc; i++){
bool b = solve(blocks);
if(b){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
return 0;
}
这里空空如也
有帮助,赞一个