Languages
来源:互联网 发布:淘宝直播广告图片 编辑:程序博客网 时间:2024/06/05 10:51
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.
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.
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.
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!
VulcanRomulan
用map数据结构一一对应,#include<iostream>#include<string>#include<cstring>#include<sstream>#include<map>using namespace std;string text,word,lan;map<string,string> m;int main(){ int T; cin>>T; getchar(); while(T--) { getline(cin,text); stringstream ss(text); ss>>lan; while(ss>>word) { for(int i=0;i<word.size();i++) if (word[i]>='A'&&word[i]<='Z') word[i]+=32; m[word]=lan; } } while(getline(cin,text)) { for(int i=0;i<text.size();i++) if (text[i]==','||text[i]=='.'||text[i]=='!'||text[i]==';'||text[i]=='?'||text[i]=='('||text[i]==')') text[i]=' '; stringstream sss(text); while(sss>>word) { for(int i=0;i<word.size();i++) if (word[i]>='A'&&word[i]<='Z') word[i]+=32; if (m.count(word)) { cout<<m[word]<<endl; break; } } } return 0;}
- Languages
- Regular Languages
- Programming Languages
- programming languages
- Context-Free Languages
- Programming / Languages / Comparison_and_Review
- Programming Languages Comparision
- Concepts in Programming Languages
- Timeline of programming languages
- Comparison of programming languages
- The Programming Languages Beacon
- Concepts in Programming Languages
- The Programming Languages Beacon
- Quotes about programming languages
- UVa10887 - Concatenation of Languages
- 10887 - Concatenation of Languages
- uva10887Concatenation of Languages
- Camel Languages Supported
- git 放弃修改区修改
- Word中表的自动断开、且断开处有空白页面的问题之解决
- 有意思网站
- Ubuntu16.04 安装openjdk-6/7/8-jdk
- 小程序月份天数
- Languages
- CEF3:CEF3关闭流程
- python运维之路——sqlalchemy ORM
- 获取jsp中多选框通过name元素取勾选的值和勾选的个数
- 用Google的gflags优雅的解析命令行参数
- javaWeb常用框架技术总结
- IntelliJ使用指南 —— Intellij IDEA自动编译不用每次make
- QtConcurrent 线程池使用
- js获取日期:昨天今天和明天、后天