Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4340 Accepted Submission(s): 2187
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; map<string,int>m; set<string>s[105]; set<string>::iterator it; string str,rstr,name="XXXXXX"; int main() { int tot=1; while(cin>>str) { if(str==name) break; rstr=str; sort(rstr.begin(),rstr.end()); if(m[rstr]==0) m[rstr]=tot++; s[m[rstr]].insert(str); } while(cin>>str) { if(str==name)break; sort(str.begin(),str.end()); if(m[str]==0) printf("NOT A VALID WORD\n******\n"); else { for(it=s[m[str]].begin();it!=s[m[str]].end();it++) cout<<*it<<endl; printf("******\n"); } } return 0; }
原文:http://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7254044.html