hdu6208(cin取消同步)

题目

题意:要寻找一个串是其他所有串的母串,如果有输出这个串,如果没有就输出No。
题解:(鶸一个,并不会AC自动机。。。。。然后发现了新大陆)string本身自带查找子串的函数,string.find(),但是cin输入30MB的数据绝对会超时,然后就看到了这样一个黑科技:cin.sync_with_stdio(false);
详情看这里:大佬博客orz
然后cin输入数据的速度就大大加快了,然后就可以愉快的补题了。

#include
using namespace std;
string s[100005];
int main()
{
    int t;
    cin.sync_with_stdio(false);
    cin>>t;
    while (t--)
    {
        int n;
        cin>>n;
        int num = 0;
        string p;
        for(int i=0;icin>>s[i];
            if(numint f=1;
        for(int i=0;iif(p==s[i])continue;
            int k=p.find(s[i]);
            if(k>p.size())
            {
                f=0;
                break;
            }
        }
        if(f)cout<else cout<<"No"<

你可能感兴趣的:((~ ̄▽ ̄)~HDU)