HDU 6208 The Dominator of Strings(stl)
来源:互联网 发布:武汉工程大学 知乎 编辑:程序博客网 时间:2024/06/05 19:31
The Dominator of Strings
Time Limit: 3000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2439 Accepted Submission(s): 879
Problem Description
Here you have a set of strings. A dominator is a string of the set dominating all strings else. The string S is dominated by T if S is a substring of T .
Input
The input contains several test cases and the first line provides the total number of cases.
For each test case, the first line contains an integerN indicating the size of the set.
Each of the followingN lines describes a string of the set in lowercase.
The total length of strings in each case has the limit of100000 .
The limit is 30MB for the input file.
For each test case, the first line contains an integer
Each of the following
The total length of strings in each case has the limit of
The limit is 30MB for the input file.
Output
For each test case, output a dominator if exist, or No if not.
Sample Input
310youbetterworsericherpoorersicknesshealthdeathfaithfulnessyoubemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulness5abccdeabcdeabcdebcde3aaaaaaaaabaaaac
Sample Output
youbemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulnessabcdeNo
Source
2017 ACM/ICPC Asia Regional Qingdao Online
Recommend
liuyiding | We have carefully selected several similar problems for you: 6216 6215 6214 6213 6212
题解:
很水的一题,暴力就可以解决,直接取最长的作为模板串,如果和他等长的串和他不相同就不可以,然后其他的串要在那个串里面找得到。。。
比赛的时候我tm也是醉了,莫名其妙wa了好几遍,最后也没发现错,后来比完赛才知道错在了取消了cin和cout的同步以后用printf就会出错了。。。我把printf改成cout就ac了,我%@#¥@#¥@#¥@,以后不能随便用取消同步了
代码:
#include<iostream>#include<cstring>#include<stdio.h>#include<math.h>#include<string>#include<stdio.h>#include<queue>#include<stack>#include<map>#include<vector>#include<deque>#include<algorithm>#define ll long long#define INF 100861111#define M (t[k].l+t[k].r)/2#define lson k*2#define rson k*2+1using namespace std;struct node{ string s;};node p[100005];string t;int main(){ std::ios::sync_with_stdio(false); int test,i,j,n,num,maxx,tag; scanf("%d",&test); while(test--) { scanf("%d",&n); maxx=0; for(i=0;i<n;i++) { cin>>p[i].s; if(p[i].s.size()>maxx) { maxx=p[i].s.size(); t=p[i].s; } } tag=1; for(i=0;i<n;i++) { if(p[i].s.size()==maxx) { if(p[i].s!=t) { tag=0; break; } } else { if(t.find(p[i].s)==string::npos) { tag=0; break; } } } if(tag) cout<<t<<endl; else cout<<"No"<<endl; } return 0;}
阅读全文
0 0
- HDU 6208 The Dominator of Strings(stl)
- HDU 6208 The Dominator of Strings
- HDU 6208 The Dominator of Strings
- hdu 6208 The Dominator of Strings
- hdu 6208 The Dominator of Strings
- hdu 6208 The Dominator of Strings
- HDU 6208 The Dominator of Strings
- HDU 6208:The Dominator of Strings(字符串匹配)
- HDU 6208 The Dominator of Strings(字符串)
- HDU 6208 The Dominator of Strings(String查找)
- HDU 6208 The Dominator of Strings (kkkkkk....mp)
- HDU 6208 The Dominator of Strings (AC自动机)
- HDU 6208 The Dominator of Strings (SAM)
- HDU 6208 The Dominator of Strings [AC自动机]
- HDU 6208 The Dominator of Strings AC自动机
- HDU 6208 The Dominator of Strings AC自动机
- HDU 6208 The Dominator of Strings 后缀自动机
- hdu 6208 The Dominator of Strings 后缀自动机 LCS
- PHP对二维数组进行双条件排序的实现
- JS完成注册页面的省市联动(JS内置对象全局函数,select标签操作)
- 正则表达式的优先级
- 第三周项目一顺序表的基本运算(1)
- 微信公共号关闭当前页
- HDU 6208 The Dominator of Strings(stl)
- 如何更加安全、高效地选择开源项目
- 一个自定义的PopupWindow的实例
- poj 4150:上机 dp
- hadoop网站日志分析(一)
- Mac PHP添加SQL Server扩展
- 内存池 (Memory Pool)
- Python with open语句
- PHP使用之网站后台上传图片出错,提示Warning: mkdir() [function.mkdir]: Permission denied……