Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss642 - | Accepted | C++11 | 0.000 | 0.000 | 1327 | 45 mins ago |
#include <bits/stdc++.h>
using namespace std;
string s;
unordered_map<string, bool> mymap;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
while(1){
cin >> s;
if (s=="XXXXXX") break;
mymap[s]= true;
}
while(1){
cin >> s;
if (s=="XXXXXX") break;
sort(s.begin(), s.end());
bool exist= false;
do{
if (mymap[s]){
exist= true;
cout<<s<<"\n";
}
}while(next_permutation(s.begin(), s.end()));
if (!exist) cout<<"NOT A VALID WORD\n";
cout<<"******\n";
}
}
No comments:
Post a Comment