ACM2015沈阳:B-Bazinga】的更多相关文章

2019.1.24 数据范围:\(n<=500,m<=2000\) 这个题最裸的暴力就是对于每个字符串,都去验证一次,时间复杂度\(O(n^2m)\) 我们发现,如果对于字符串\(i\),前\(i-1\)个字符串都是它的子串,假如存在一个字符串\(j\),使得\(i\)是\(j\)的子串,那么\(j\)就不需要去验证前\(i-1\)个字符串 这样就很好想到,我们对于字符串\(i\),只需要记下\(i-1\)中最后一个不是它子串的字符串,就能将时间复杂度优化到\(O(nm)\) 代码: #inc…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 214    Accepted Submission(s): 89 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For n…
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: 我没有读题,只是队友给我解释了题意,然后我根据题意写的题. 大概意思是给n个字符串,从上到下依次标记为1——n,寻找一个标记最大的串,要求这个串满足:标记比它小的串中至少有一个不是它的子串. 输入: 第一行输入一个整型t,表示共有t组数据. 每组数据首行一个整型n,表示有n个串. 接下来n行,每行…
题意:给你\(n\)个字符串,\(s_1,s_2,...,s_n\),对于\(i(1\le i\le n)\),找到最大的\(i\),并且满足\(s_j(1\le j<i)\)不是\(s_i\)的子串. 题解:直接\(O(n^2)\)然后跑kmp匹配,这里注意要剪枝,不然会T,也就是说对于前\(i-1\)个串,如果它是后面某个串的子串,那么我们就不用对它跑kmp,因为它后面的某个串包含了它. 代码: int t; int n; string s[N]; int ne[N]; bool st[N]…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3509    Accepted Submission(s): 1122 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.Fo…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2078    Accepted Submission(s): 642 Problem Description  to n, you should find the largest i (1≤i≤n) such that there exists an integer j (…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 593    Accepted Submission(s): 241 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For …
今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description ACM ICPC is launching a thic…
5510 Bazinga 题意:给出n个字符串,求满足条件的最大下标值或层数 条件:该字符串之前存在不是 它的子串 的字符串 求解si是不是sj的子串,可以用kmp算法之类的. strstr是黑科技,比手写的kmp快.if(strstr(s[i], s[j]) == NULL),则Si不是Sj的子串. 还有一个重要的剪枝:对于一个串,如果当前找到的串是它的母串,则下一次这个串不用遍历. #include <set> #include <queue> #include <cst…
Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 70    Accepted Submission(s): 62 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yun…