535D Tavas and Malekas】的更多相关文章

535D - Tavas and Malekas 题目大意:给你一个模板串,给你一个 s 串的长度,告诉你 s 串中有 m 个模板串并告诉你,他们的其实位置, 问你这样的 s 串总数的多少,答案对1e9+7取模. 我感觉我英语是不是不行啊,我以为他的意思是他里面一共只有m个匹配串,想着没有其他的匹配串,感觉 好麻烦好麻烦好麻烦啊!!!!!! 思路:最暴力的思路,他给你一个匹配串的位置,你就在s串上更新,如果遇到没有已经被更新而且字符不同时 输出0,然后统计剩下的未知字符的个数x,答案就是 (26…
题目链接 又复习了一遍kmp....之前都忘光了 #include<bits/stdc++.h> using namespace std; #define pb(x) push_back(x) #define ll long long #define mk(x, y) make_pair(x, y) #define lson l, m, rt<<1 #define mem(a) memset(a, 0, sizeof(a)) #define rson m+1, r, rt<&…
题目大意 给你一个串和m个下标 问你一个长度为n的串每一个下标开始的后缀的前缀都包含给定的串的方案数 分析 对于给定的串求出z数组 对于两个串不重叠的情况就是中间都不包含的数随便填即可 对于重叠的情况判断相交部分的左端点的z[i]是否大于等于重叠长度即可 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #in…
题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of…
Codeforce 535 D. Tavas and Malekas 解析(字串匹配) 今天我們來看看CF535D 題目連結 題目 給你一個字串$p$和一些$index$代表字串$p$在哪些位置會和長度為$n$的字串$s$匹配,求有多少種$s$的可能性. 前言 我還是只會$hash$ @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 $p$沒有覆蓋到的$index$數量記做$cnt$,如果那些會重疊的$p$沒有矛盾的話,那答案就是…
题面 题目描述 给你两个字符串a和b,告诉所有你b在a中一定匹配的位置,求有中不同的字符串a.a的长度为n,b的长度为m,一定匹配的位置有p个.若b在a中的一定匹配的位置为x,说明a[x-x+m-1]=b[1-m].a和b中只有小写字母. 输入格式 第一行两个字符串n.p:(1<=n<=100000, 0<=p<=n-m+1) 第二行有一个字符串b:(1<=m<=n) 第三行有p个数:这p个一定匹配的位置. 输出格式 一个数:答案.模10^9+7. 样例 Input1…
题目链接:http://codeforces.com/contest/536/problem/B 一个原始字符串,一个未知字符串,每一次从pos[i]开始覆盖未知字符串,问最后字符串的形式,以及判断过程中是否有矛盾. 过程中pos是升序的,所以如果任意连续两次操作,如果覆盖范围不重叠,则没事,否则需要判断原始字符串某一个后缀是否同时也是前缀.这个可以用next数组,z函数,后缀数组等计算. #include <iostream> #include <vector> #include…
KMP,先预处理按每个节点标记,扫一遍更新每个匹配位置,最后kmp判断是否有重合而且不相同的地方 注意处理细节,很容易runtime error #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #inclu…
http://codeforces.com/contest/535/problem/D 如果真的要把m个串覆盖上一个串上面,是可以得,不会超时. 要注意到一点,全部覆盖后再判断时候合法,和边放边判断,结果是一样的,后者还更难做到. 那么就是先按顺序把串覆盖上去,已经存在的就不去覆盖了,然后kmp一次记录匹配位置,判断即可. 用DFS覆盖,DFS回溯的时候记录一个数组tonext[i]表示第i个点的第一个空位是tonext[i],这样覆盖上去就是O(n) #include <cstdio> #i…
[链接] 我是链接,点我呀:) [题意] 给你n个位置,然后让你从某些位置开始的|p|个位置,填上p这个字符串. 问你填的时候是否会发生冲突->输出0 否则输出最终n个位置组成的可能的字符串的总数 [题解] 扩展KMP. 画个图会发现. 相邻的两个填写操作. 只要发生了重叠.想要看有没有冲突. 相当于询问从某个位置开始的后缀是否和从0开始的后缀一样. 即看看lcp的长度是否大于等于相交部分即可. 会发现第i-2个字符串如果没有和第i-1个字符串发生冲突. 那么和第i个字符串如果发生了重叠,那么肯…
题意简述 有一个空着的长度为\(n\)的字符串\(ans\),再给出一个长度为\(m\)的序列\(a\),现要在序列中每个元素\(a_i\)的位置开始都规定必须为一个给定的字符串\(s\).问字符串\(ans\)的可能种类. 解法 主要考虑有可能\(a_i\)之间互相冲突导致直接输出\(0\),于是我们需要快速判断当前字符串\(s\)的首与尾是否匹配.显然有两种可行解法,第一种是KMP,第二种是玄学的字符串哈希.但是写这篇题解的蒟蒻不想打KMP,于是就写了一个哈希. 这里的哈希其实只用单哈希即可…
B. Tavas and Malekas time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n co…
这场比赛并没有打现场,昨天晚上做了ABCD四道题,今天做掉了E题 以前还没有过切完一场比赛的所有题呢~爽~ A. Tavas and Nafas   Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating system is Tavdroid, and its keyboard doesn't have…
C. Tavas and Karafs #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <vector> #include <set> #include <map> #include <stack&g…
Tavas and Karafs time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almos…
 Tavas and Nafas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating…
C. Tavas and Pashmaks   Tavas is a cheerleader in the new sports competition named "Pashmaks". This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly …
[CF536D]Tavas in Kansas 题目大意: 一张\(n(n\le2000)\)个点,\(m(m\le10^5)\)条边的无向带权连通图(权值可以为负).A.B两人分别在\(s,t\)点进行博弈.A先手,每次每人可以选择一个数\(x\),并取走到当前位置距离\(\le x\)的点,自己的得分加上这些点的权值之和.每次至少取走一个点,去过的点不能再取.取完所有的点后,得分最高者胜.若每个人都按照最后策略进行游戏,求最后的赢家. 思路: 首先求\(s,t\)的单元最短路.对于每个点,我…
535C - Tavas and Karafs 思路:对于满足条件的r,max(hl ,hl+1 ,hl+2 ,......,hr )<=t(也就是hr<=t)且∑hi<=t*m.所以通过这个条件二分找出最大的r. 二分的下界为1,上界为使得hi等于t的i(hi=t    ==>    a+(i-1)*b=t    ==>    i=(t-a)/b+1) 代码: #include<bits/stdc++.h> using namespace std; #defin…
535B - Tavas and SaDDas 方法一:打表大法. 代码1: #include<bits/stdc++.h> using namespace std; ]={,,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,,,,,,, ,…
Tavas and Karafs Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/problem/A Description Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kin…
B. Tavas and SaDDas Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/problem/B Description Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. Th…
A. Tavas and Nafas Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/problem/A Description Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating syste…
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing…
题目链接:Tavas and SaDDas Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told…
题目链接 Tavas and Pashmaks 题目大意:n个人比赛,游泳和赛跑,游泳距离S,赛跑R.每个人对应两个速度(陆地和水上的),如果存在S,R,使得第i个人胜利,那么输出i 题目要求输出所有的i 维护一个凸壳即可. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a);…
Tavas and Karafs Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 535C Description Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they…
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http://blog.csdn.net/libin56842/article/details/45082747 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> us…
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight",…
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> #include <cmath> #include <vector> using namespace std; ; const int INF = 0x3f3f3f3f; ] = {, }; int a[MAXN]; in…