C.Cheering To boost contestants' performances in the 20th La Salle - Pui Ching Programming Challenge, the organizers have bought N robots to cheer for them. Each robot is supposed to display cheering slogans, letter by letter. Unfortunately, due to s…
D.Distribution of Days The Gregorian calendar is internationally the most widely used civil calendar. It is named after Pope Gregory XIII, who introduced it in October 1582. In the Gregorian calendar, there are 28 days in February in a common year an…
A. Ambiguous Dates There are two popular formats for representing a date: day/month/year or month/day/year. For example, today can be represented as 15/8/2017 or 8/15/2017. Sometimes (like on today), using one way or another should pose no confusion…
西瓜队(划掉),Kuma Rider久违的第一场训练,四小时瞎打.jpg A.水题,排序 #include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<cstring> #include<string> #include<vector> #include<map> #include<functional&g…
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=28214 题目大意:源串有如下变形:每次将串切为两半,位置颠倒形成新串.问经过K次变形后,与目标串相同的变形方案数.mod 1000000007. 解题思路: 奇葩的字符串DP.照着别人的题解写的,解释不出原理是什么. 首先统计出经过1次变形,就能和目标串相同的中间产物串(包含源串)的个数cnt.len表示源串长度,那么len-cnt就表示和目标串不同的个数. 用…
原文链接http://www.cnblogs.com/zhouzhendong/p/9010851.html 题目传送门 - Codeforces 316G3 题意 给定一个母串$s$,问母串$s$有多少本质不同的子串$t$是“好”的. 一个字符串$t$是好的,仅当$t$满足了所有的$n$个条件. 第$i$个条件用一个三元组$(p_i,L_i,R_i)$来描述. 其中$p_i$为一个字符串,$L_i,R_i$为整数,且$L_i\leq R_i$. 仅当字符串$t$在$p_i$中出现次数在$L_i…
题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters of Pushkin’s works are Onegin \cite{onegin}, Dubrovsky \cite{dubrovsky} and Tsar Saltan \cite{saltan}. \begin{thebibliography}{99} \bibitem{saltan} A…
题目链接:https://codeforces.com/problemset/problem/1056/E One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe…
题目链接:http://codeforces.com/problemset/problem/883/H Time limit: 3000 ms Memory limit: 262144 kB Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits. He wants to rearrange the symbols in s and cut it into th…
题目链接: http://codeforces.com/contest/1183/problem/H 题意: 给出一个长度为$n$的字符串,得到$k$个子串,子串$s$的花费是$n-|s|$ 计算最小花费 数据范围: $1 \le n \le 100, 1 \le k \le 10^{12}$ 分析: dp依然还是那么神奇 定义$dp[i][j]$为考虑前$i$个字符,删除$j$个字符的方案数 首先$dp[i][j]=dp[i-1][j]+dp[i-1][j-1]$ 前者为不保留第$i$个字符,…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF109D.html 题目传送门 - CF109D 题意 给定两个字符串 $a,b$ ,求一组 $i,j$ 使得 $f(a,i,j)=b$ .如果无解输出 "-1 -1" ,如果多组解,输出 i 尽量大的:如果 i 相同,输出 j 尽量小的. 其中 $f(s,i,j) = s[i+1 \cdots j-1] + r(s[0 \cdots i]) + r(s[j\cdots n-1])$ . $n$…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF235C.html 题目传送门 -  CF235C 题意 给定一个字符串 $s$ ,多组询问,每组询问的形式为一个字符串 $T$ ,问 $S$ 有多少个子串与 $T$ 循环同构.(如果 $S$ 有多个相同子串都同构,则算多次) $|S|\leq 10^6,\sum |T|\leq 10^6$ 题解 以后坚决不念诗了!中午作死念诗,下午就被一个傻逼错误续了 3 个多钟头. 做法: 给 $S$ 建一个 SAM…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF542E.html 题目传送门 - CF452E 题意 给定三个字符串 $s1,s2,s3$ ,对于所有 $L\in{1,2,\cdots,min(|s1|,|s2|,|s3|)}$ ,输出 $f(L)$ . 其中 $f(L)$ 表示满足 $s_k[i_k,\cdots,i_k+L-1]$ 全部相同的 $i_1,i_2,i_3$ 的个数. 答案对 $10^9+7$ 取模. $|s1|+|s2|+|s3|\l…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF-100543G.html 题目传送门 - CF-Gym100543G 题意 你可以对一个字符串进行以下两种操作: 1.  在其头或者尾部加入一个新字符 2.  翻转当前字符串,并把他拼接在当前字符串的前面或者后面 给你 T 组询问,每组询问一个字符串,问你至少要多少次操作才能生成这个串. 字符集 = ${'A','C','G','T'}$ ,字符串串长 $\leq 100000$ 题解 第一次写回文自动机…
原文链接https://www.cnblogs.com/zhouzhendong/p/9256033.html 题目传送门 - CF873F 题意 给定长度为 $n$ 的字符串 $s$,以及给定这个字符串每一个位置是否 “禁止结尾” 的信息. 一个字符串 $a$ 的价值为 $|a|\times f(a)$ . 其中 $f(a)$为 $a$ 在 $s$ 中的匹配次数(如果匹配的结尾为禁止结尾点,那么不算匹配成功) 问在所有的字符串 $a$ 中,$\max(|a|\times f(a)$ 的值. $…
题目链接:http://codeforces.com/problemset/problem/603/A 题意: 给定一个 $01$ 串,我们“交替子序列”为这个串的一个不连续子序列,它满足任意的两个相邻的数字不相等. 现在,我们要对这个 $01$ 串的某一段非空连续子串进行反转操作,即将这一段上的所有 $0$ 变为 $1$,所有 $1$ 变为 $0$. 然后,求问进行了有且仅有一次的反转操作后,求该串的最长交替子序列的长度. 题解: 首先,对于一个 $01$ 串,对其进行压缩操作,即将所有连续的…
Cpdeforces 762C 题目大意: 给定两个字符串a,b\((len \leq 10^5)\),让你去b中的一个连续的字段,使剩余的b串中的拼接起来的两个串是a穿的子序列.最大化这个字串的长度. 题解: 删除这个操作不太好说,我们先换一个思路:实际上删除就是在b串中分别取出两个不相交的前缀和后缀,使得这两个串在a串中不重叠地出现 我们发现答案具有显然的单调性,所以我们首先二分答案(二分删去的字串长度). 现在来考虑如何进行判定: 一个很直接的思路就是枚举所有的符合条件的前缀和后缀 然后对…
A - Email Aliases Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u Submit Status Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect that the case of the letters doesn't matt…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF700E.html 题解 首先建个SAM. 一个结论:对于parent树上任意一个点x,以及它所代表的子树内任意一个点y,设节点y代表的最长串为S,设节点x代表的串为T1,T2,T3,...,设 F(S,T) 表示串T在S中的出现次数,则 F(S,T1) = F(S,T2) = F(S,T3) = ... 证明:假设串 Ta 和 Tb 在 S 中的出现次数不同,且 |Ta|+1=|Tb| 则必然存在一个位置…
题目链接:点击打开链接 #include<stdio.h> #include<iostream> #include<string.h> #include<set> #include<vector> #include<map> #include<math.h> #include<queue> #include<string> #include<stdlib.h> #include<a…
Regex reg = new Regex(@"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"); if (!reg.IsMatch(txtorgqty.Text)) "^\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\d+)|(0+))$" //非正…
链接:http://codeforces.com/gym/101116 学弟写的,以后再补 #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <map> #include <vector> using namespace std; map<string,int>v,ans; vector<in…
链接:http://codeforces.com/gym/101116 题意:给出n个点,要求一个矩形框将(n/2)+1个点框住,要面积最小 解法:先根据x轴选出i->j之间的点,中间的点(包括两边)按照y排序,固定一边X=(xj-xi),Y就枚举点两端的Y坐标,细节是注意要取(n/2)+1个点 事实上这样取里面一定符合要求 #include <iostream> #include <cstdio> #include <algorithm> #include &l…
链接:http://codeforces.com/gym/101116 题意:选六个数,必须出现次数最多,且数字最小,如果出现7优先加入7 解法:排序,出现7优先加入7,最后再将6个数排序 #include<bits/stdc++.h> using namespace std; struct P { int num,pos,M; }He[1000]; bool cmd(P a,P b) { if(a.pos==b.pos) { return a.M<b.M; } else { retur…
链接:http://codeforces.com/gym/101116 学弟做的,以后再补 #include <iostream> #include <stdio.h> #include <cstring> #include <string> using namespace std; int a[505]; int main(){ int T; cin>>T; string s[505]; while(T--){ memset(a,0,sizeo…
1. 要求 对List列表中的数据进行排序(正序.倒序),列表中的数据包括:整型(Integer).字符串(String).日期(Date)等.对于字符串,要求允许对它按照整型进行排序. 2. 实现思路 1. 对于整型.字符串.日期等数据,可以直接调用Collections.sort方法实现排序(正序.倒序). 2. 对于字符串按照整型排序,可以写一个类实现Comparable接口,在compare方法中将字符转换为整型进行比较:然后再调用Collections.sort的方法,传进一个Comp…
区分正斜杠与反斜杠: 正斜杠:http://.http紧跟着的斜杠,离手输入最近的斜杠,shift中间斜杠.45度角斜杠.正斜杠不需要转义 反斜杠:回车与空格之间.程序表示时需要转义成\\. str.replace(/\\/,/); 1>要想定义字符串a\b\c需要这样写var str = "a\\b\\c"; 2>alert(str.replace(/\\/g,"/"));将a\b\c 修改为a/b/c var str = "a\\b\\c&…
题目链接:D. Frets On Fire 思路:明明可以离散化+二分写,思路硬是歪到了线段树上,自闭了,真实弟弟,怪不得其他人过得那么快 只和查询的区间长度有关系,排完序如果相邻的两个点的差值小于等于查询的区间长度,那么给结果带来的变化就会新增差值个数,如果大于区间长度那么就会新增区间长度个数 维护的话,线段树和二分都可以,二分需要离散化处理,再给差值排个序,每次找到第一个大于当前区间长度的差值位置就好了,(没实现,但是理论上应该没问题) 线段树直接动态开点可以不用离散化.. 实现代码: #i…
I.Yet another A + B You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct? Input There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10100), each on a separate line of input. O…
这个题就是两个队,看最多能赢的个数,然后比较一下,看两个队是都能赢彼此,还是只有一个队赢的可能性最大.表达能力不好,意思差不多... 和田忌赛马有点像,emnnn,嗯. 代码: 1 #include<cstring> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 using na…