CSU
来源:互联网 发布:原生js实现todo list 编辑:程序博客网 时间:2024/06/17 18:19
Description
The Enterprise has encountered a planet that at one point had been inhabited. The only remnant from the prior civilization is a set of texts that was found. Using a small set of keywords found in various different languages, the Enterprise team is trying to determine what type of beings inhabited the planet.
Input
The first line of input will be N (1 ≤ N ≤ 100), the number of different known languages. The next N lines contain, in order, the name of the language, followed by one or more words in that language, separated with spaces. Following that will be a blank line. After that will be a series of lines, each in one language, for which you are to determine the appropriate language. Words consist of uninterrupted strings of upper or lowercase ASCII letters, apostrophes, or hyphens, as do the names of languages. No words will appear in more than one language. No line will be longer than 256 characters. There will be at most 1000 lines of sample text. Every sample text will contain at least one keyword from one of the languages. No sample text will contain keywords from multiple languages. The sample text may contain additional punctuation (commas, periods, exclamation points, semicolons, question marks, and parentheses) and spaces, all of which serve as delimiters separating keywords. Sample text may contain words that are not keywords for any specific language. Keywords should be matched in a case-insensitive manner.
Output
For each line of sample text that follows the blank line separating the defined languages, print a single line that identifies the language with which the sample text is associated.
Sample Input
4Vulcan throks kilko-srashiv k'etwelRomulan Tehca uckwazta Uhn NeemastaMenk e'satta prah ra'sataRussian sluchilosDif-tor heh, Spohkh. I'tah trai k'etwelUhn kan'aganna! Tehca zuhn ruga'noktan!
Sample Output
VulcanRomulan
Hint
#include <stdio.h>#include <iostream>#include <map>#include <string.h>#include <sstream>using namespace std;map<string,string> m;int main(){ string s; int n; cin>>n; while(n--){ string t,lan; cin>>lan; getchar(); //cout<<lan<<endl; getline(cin,s); int len = s.length(); for(int i=0;i<len;i++){ if(s[i]>='A'&&s[i]<='Z'){ s[i]+=32; } } //cout<<s<<endl; stringstream ss(s); while(getline(ss,t,' ')){ m[t]=lan; } } while(getline(cin,s)){ int len = s.length(); for(int i=0;i<len;i++){ if(s[i]==','||s[i]=='.'||s[i]=='?'||s[i]=='!'||s[i]==';'||s[i]=='('||s[i]==')'){ s[i]=' '; } } for(int i=0;i<len;i++){ if(s[i]>='A'&&s[i]<='Z'){ s[i]+=32; } } stringstream ss(s); string t; while(getline(ss,t,' ')){ if(m.count(t)){ cout<<m[t]<<endl; break; } } } return 0;}
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- UVa 12118 Inspector's Dilemma (欧拉道路)
- spring学习之自动装配
- Spring AOP
- ajax回调函数动态加载的标签里面js事件不执行
- 剑指offer:跳台阶
- CSU
- ASP.NET中的富文本编辑控件(html文本编辑控件)整理
- Unity 从Apex学到的一种提高模块扩展性的方法
- 初步接触HTML5
- CSDN博客悄悄修改后台排名规则?
- 2分钟治好你的拖拖拖拖拖拖拖拖拖延症
- ant匹配url
- 架构师日记——Nginx反向代理、动静分离和负载均衡
- 泛型