Tanky WooRSS

HDU/HDOJ 1113 Word Amalgamation(水题)

29 Jun 2011
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

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

代码:

// Author: Tanky Woo
// Blog: www.WuTianQi.com
// Title: HDOJ 1113 Word Amalgamation
// About: 字符串

#include 
#include 
#include 
#include 
using namespace std;

map 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::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";

    }
}