随笔分类 - ACM--字符串
摘要:http://codeforces.com/contest/701 A - Cards 水 1 // #pragma comment(linker, "/STACK:102c000000,102c000000") 2 #include <iostream> 3 #include <cstdio> 4
阅读全文
摘要:http://codeforces.com/contest/699 ALaunch of Collider 题意:n个球,每个球向左或右,速度都为1米每秒,问第一次碰撞的时间,否则输出-1 贪心最短时间一定在RL中,R右边一定有L,L左边一定有R 1 // #pragma comment(linke
阅读全文
摘要:2016 Multi-University Training Contest 2 5734 Acperience 官方题解 直接队友代码 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <sstrea
阅读全文
摘要:A - Pineapple Incident 1 #pragma comment(linker, "/STACK:102c000000,102c000000") 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 #inc
阅读全文
摘要:A - Fashion in Berland 水 1 // #pragma comment(linker, "/STACK:102c000000,102c000000") 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5
阅读全文
摘要:https://icpc.baylor.edu/regionals/finder/north-america-qualifier-2015 一个人打。。。。 B 概率问题公式见代码 F 水题 输出字符串中缺少的字母 G 过河的经典问题 多个人过河每次船上必须有一人问最短时间 H 水题 旋转矩阵再输出
阅读全文
摘要:直接模拟或者KMP 1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 #include <algorithm> 5 #include <cmath> 6 #include <cstdlib> 7 using name
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 double a; 7 char s[100]; 8 int fun(char s[]) { 9 if(strcmp(s,"B]") == 0)return 0; 10 if(strcmp(s,"KB]") == 0)...
阅读全文
摘要:题意:找元素关于对角线左或右对称的最大矩阵 思路:左右对角线只需要遍历一条就可以了。只要当前点往上遍历和往后遍历一样就可以。
阅读全文
摘要:枚举长度最短的字符串的所有子串,再与其他串匹配。 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<cstdlib> 6 #include<string> 7 #i
阅读全文
摘要:最长回文串模板题 Manacher 算法 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<cstdlib> 6 #include<string> 7 #inclu
阅读全文
摘要:题意:给你一个串,问期中至少出现m次的最长子串及其起始位置的坐标。思路:hash+LCP+二分答案 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 40000 + 10; 7 const in...
阅读全文
摘要:题意:给你N个串,求一个串在大于等于N/2的模板串中连续出现。如果有多解按字典序最小输出。白书模板题。二分答案+合并模板串成一个新串,扫秒新串的height数组。考查后缀数组+LCP 1 #include 2 #include 3 #include 4 using namespace std...
阅读全文
摘要:题意:给出一个n*m的字符矩阵T,你的任务是找出给定的x*y的字符矩阵P在T中出现了多少次.思路:要想整个矩阵匹配,至少各行都得匹配。所以先把P的每行看做一个模式串构造出AC自动机,然后在T中的各行逐一匹配,找到P中每一行的所有匹配点。只要在匹配时做一些附加操作,就可以把匹配出来的单一的行拼成矩形。...
阅读全文
摘要:题意:给你 k 个模板串,然后给你一些字符的出现概率,然后给你一个长度 l ,问你这些字符组成的长度为 l 的字符串不包含任何一个模板串的概率。思路:AC自动机+概论DP首先用K个模板构造好AC自动机。题目上说长L的新串的子串不包含任何一个K串,其实就是说在构造好的树中,从根往下走L步都不包含K个模...
阅读全文
摘要:在文本串中找出现次数最多的子串。思路:AC自动机模板+修改一下print函数。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10...
阅读全文
摘要:题意:给你一个01串,必须替换一次,且替换的为子串。问换完后,最大01串长度。 1 #include 2 typedef long long ll; 3 using namespace std; 4 int main() 5 { 6 int n,sum = 1; 7 string ...
阅读全文
摘要:ac自动机模板题链表写法: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 #define T_size 1000000 7 #define P_size 50 8 #define Total_p 10000...
阅读全文
摘要:练习string最小变换次数下,且字典序最小输出回文串。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 const double e...
阅读全文
摘要:学习string 1 #include 2 #define eps 1e-8 3 #define M_PI 3.141592653589793 4 const int N = 100005; 5 using namespace std; 6 7 string st; 8 vectorv1,v2;...
阅读全文

浙公网安备 33010602011771号