uva10887 Concatenation of Languages
来源:互联网 发布:怎么购买备案域名 编辑:程序博客网 时间:2024/06/18 17:06
A language is a set of strings. And the concatenation of two languages is the set of all strings that
are formed by concatenating the strings of the second language at the end of the strings of the first
language.
For example, if we have two language A and B such that:
A = {cat, dog, mouse}
B = {rat, bat}
The concatenation of A and B would be:
C = {catrat, catbat, dograt, dogbat, mouserat, mousebat}
Given two languages your task is only to count the number of strings in the concatenation of the
(1 ≤ T ≤ 25). Then T test cases follow. The first line of each test case contains two integers, M and
N (M, N < 1500), the number of strings in each of the languages. Then the next M lines contain the
strings of the first language. The N following lines give you the strings of the second language. You
can assume that the strings are formed by lower case letters (‘a’ to ‘z’) only, that they are less than
10 characters long and that each string is presented in one line without any leading or trailing spaces.
with the serial number of the test case, followed by the number of strings in the concatenation of the
are formed by concatenating the strings of the second language at the end of the strings of the first
language.
For example, if we have two language A and B such that:
A = {cat, dog, mouse}
B = {rat, bat}
The concatenation of A and B would be:
C = {catrat, catbat, dograt, dogbat, mouserat, mousebat}
Given two languages your task is only to count the number of strings in the concatenation of the
two languages.
Input
(1 ≤ T ≤ 25). Then T test cases follow. The first line of each test case contains two integers, M and
N (M, N < 1500), the number of strings in each of the languages. Then the next M lines contain the
strings of the first language. The N following lines give you the strings of the second language. You
can assume that the strings are formed by lower case letters (‘a’ to ‘z’) only, that they are less than
10 characters long and that each string is presented in one line without any leading or trailing spaces.
The strings in the input languages may not be sorted and there will be no duplicate string.
Output
with the serial number of the test case, followed by the number of strings in the concatenation of the
second language after the first language.
题意:连接A B两个集合内的字符串,输出有几种不同组合
#include <iostream>#include <cstdio>#include <string>#include <set>#include <vector>using namespace std;int main(){ int t;cin >>t; for(int j=1;j<=t;j++) { int m,n; cin>>m>>n; getchar(); char a[105],b[105]; string s1,s2,s3; vector<string> s,ss; set<string> x; for(int i=1;i<=m;i++) { getline(cin,s1); s.push_back(s1); } //cout<<"``````````"<<endl; for(int i=1;i<=n;i++) { getline(cin,s2); ss.push_back(s2); } set<string>::iterator it; for(int i=0,l=0;i<m;i++) for(int k=0;k<n;k++) { //cout <<s[i]<<"0"<<ss[k]<<endl; s1=s[i];s2=ss[k]; s3=s1+s2; //cout <<s3<<endl; x.insert(s3); } //cout <<"========="<<endl; //for(it=x.begin();it!=x.end();it++) //cout <<*it<<endl; //for(int i=0;i<s.size();i++) // printf("%s\n",s[i]); printf("Case %d: %d\n",j,x.size()); }}
阅读全文
0 0
- UVa10887 - Concatenation of Languages
- uva10887 Concatenation of Languages
- [哈希]Concatenation of Languages uva10887
- 10887 - Concatenation of Languages
- 10887 - Concatenation of Languages
- Uva 10887 Concatenation of Languages
- UVa 10887 - Concatenation of Languages
- uva 10887 - Concatenation of Languages
- UVa 10887 - Concatenation of Languages
- UVA 10887 Concatenation of Languages
- uva 10887 - Concatenation of Languages
- uva 10887 - Concatenation of Languages
- UVA 10887 Concatenation of Languages
- UVa:10887 Concatenation of Languages
- uva 10887Concatenation of Languages
- UVa 10887 - Concatenation of Languages
- UVa 10887 - Concatenation of Languages
- UVA 10887 Concatenation of Languages
- Python面试题
- 群居影响力
- LVS-NAT
- WPF 使用匿名类作为显示的Model
- 浙江中医药大学暑期训练测试赛八G
- uva10887 Concatenation of Languages
- [洛谷P1273]有线电视网
- C语言之二叉树(包括遍历的实现)
- ViewPager数据加载错乱的问题
- android自定义view的长按事件的执行时间
- Android AES加密工具类
- python爬虫
- 利用Dozer实现vo-Entiy-Model中属性的复用
- Oracle:查找表的主键,外键,唯一性约束,索引