HDU/HDOJ 1113 Word Amalgamation(水题)

题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1113

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Author: Tanky Woo
// Blog: www.WuTianQi.com
// Title: HDOJ 1113 Word Amalgamation
// About: 字符串
 
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
map<string, string> str;
string s, t;
 
int main()
{
	freopen("input.txt", "r", stdin);
	while(cin >> s && s != "XXXXXX")
	{
		t = s;
		sort(s.begin(), s.end());
		str[t] = s;
	}
	while(cin >> s && s != "XXXXXX")
	{
		bool flag = 0;
		t = s;
		sort(s.begin(), s.end());
		for(map<string, string>::iterator it=str.begin(); it!=str.end(); ++it)
			if(it->second == s)
			{
				cout << it->first << endl;
				flag = 1;
			}
		if(flag == 0)
			cout << "NOT A VALID WORD\n";
		cout << "******\n";
 
	}
}

发布者

Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

发表评论

电子邮件地址不会被公开。 必填项已用*标注