ZOJ Special AC String 水】的更多相关文章

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3702 题目大意: 对于给定的一个字符串,满足如下要求输出AC,否则WA(好吧我简写) 给定字符串只有ZOJ三个字母组成.Z和J只能有一个并且Z在左边 J之后的O个数必须大于Z之前的O个数 Z和J之间O的个数必须不大于J之后的O的个数,并且他们都大于0 #include<cstdio> #include<cstring> const int MAXN=1001;…
Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the binary string has at least as many 1's as 0's. Given a special string S, a move consists of choosing two…
Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the binary string has at least as many 1's as 0's. Given a special string S, a move consists of choosing two…
Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the binary string has at least as many 1's as 0's. Given a special string S, a move consists of choosing two…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/special-binary-string/description/ 题目描述: Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number…
761. Special Binary String 题意: 一个符合以下两个要求的二进制串: \(1.串中包含的1和0的个数是相等的.\) \(2.二进制串的所有前缀中1的个数不少于0的个数\) 被称为特殊二进制串 要求我们任意交换两个相邻的特殊二进制串(可以交换任意次)使得最终得到的序列的字典序最大,并且满足是特殊二进制串. 思路: 我们可以将1看作是上升,0是下降,那么可以这样 然后我们可以找最外层符合要求的子串也就是最底部从水平线开始又降到水平线的段,可以发现找这样的串只要统计一个cnt…
题意:先给你一个不超过1000000长度的大串s:接下来输入一个n代表接下来输入的小串个数,小串长度不超过6. 小串分两种类型0和1类型. 0类型表示小串在大串中的最大匹配个数就是常规的AC自动机的做法. 1类型表示小串在大串中不能重合的最大匹配数. 依次输出结果.(所有的串只包含小写字母) 按样例输出,注意每组测试数据后有一个换行. 题意我不想写了抄的,抄这里的 (不好意思啦) 0 类型的就是最开始的模板题 1 类型的处理方式就是,在建立字典树的时候弄一个dep数组,记录每一个节点的深度 然后…
意甲冠军: 到原始字符串.给n字符串,每个字符串都有一个属性,属性0代表重叠,1代表不能重叠 请各多少次出现的字符串 思维: 为了便于建立两台机器自己主动(0一个.1一个) 然后,它可以重叠非常好做,谁做 不可重叠的话须要记录两个东西 len[i]代表每一个串的长度,used[i]代表每一个串在之前出现的位置,初始化-1 然后遍历到的时候对于当前位置 j. 必须j>=used[i]+len[i] 才干算出现.而且更新 须要注意的是: 会出现相同属性而且相同的串. 我处理的方式就是排序.按id排序…
One day, Nobita found that his computer is extremely slow. After several hours' work, he finally found that it was a virus that made his poor computer slow and the virus was activated by a misoperation of opening an attachment of an email. Nobita did…
题目链接:  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3494 题目大意:给定一些被禁止的BCD码.问指定范围内不含有任何这些禁止的BCD码的数的个数. 解题思路: AC自动机部分: 首先insert这些被禁止的BCD码. 然后打一下自动机前后状态的转移的表,用BCD[i][j]表示自动机状态i时,下一个数字是j的自动机的下一个状态. 一开始我考虑最先dfs的位在自动机的位置,后来发现SB了.AC自动机有一个roo…
水 Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information Theory is one of the most popular courses in Marjar University. In this course, there is an important chapter about information entropy. Entropy is…
最近正在学AC自动机,按照惯例需要刷一套kuangbin的AC自动机专题巩固 在网上看过很多模板,感觉kuangbin大神的模板最为简洁,于是就选择了用kuangbin大神的模板. AC自动机其实就是字典树和KMP的结合,然后去思考一下KMP的原理,然后就是在字典树上实现KMP 这里最重要的思想可能就是fail的思想,就像KMP一样,匹配失败后,有一个next的数组去回溯(最长公共前缀后缀) 如何理解了KMP的话,感觉这个不会很难理解,字典树是一个非常简单的东西就不用讲了吧. HDU - 222…
GCD Reduce Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge You are given a sequence {A1, A2, ..., AN}. You task is to change all the element of the sequence to 1 with the following operations (you may need to apply it multiple ti…
两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2) 让你判断第n项是否能被3整除. 1.ZOJ 2723 Semi-Prime http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1723 打表即可. #include<cstdio>…
啦啦啦,水一发准备去复习功课~ ------------------------------------------水一发的分割线------------------------------------------ http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1514 水题,没有一次AC我很惭愧,竟然忘了输出总共的个数..... #include<cstdio> #include<cstring> const…
题意: 问A到B之间的所有整数,转换成BCD Code后, 有多少个不包含属于给定病毒串集合的子串,A,B <=10^200,病毒串总长度<= 2000. BCD码这个在数字电路课上讲了,题干也讲的很详细. 数位DP的实现是通过0~9 ,并不是通过BCD码 所有我们需要先把字串放入AC自动机,建立一个BCD数组 因为BCD码是一个4位二进制数,但是tire图上全是0,1, 所以对于一个数字,我们的要在转移4次, 如果中间出现了病毒串就return -1 表示不能转移, BCD[i][j]表示在…
Information Entropy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3827 Description Information Theory is one of the most popular courses in Marjar University. In this course, there is an impo…
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1603 题意 问使m个n长碱基序列汉明码最小的序列 思路 明显,取最频繁的 代码 #include <algorithm> #include <cassert> #include <cmath> #include <cstdio&…
Lweb and String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S. Oneday, he decided to transform this string to a new sequence. You need help him determine this transformation to get a sequence which has the longe…
B. Equidistant String Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/B Description Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings conta…
这题主要就是解码过程很恶心,不能用char存,一共wa了20发 题意:先给n串加密后的字符,然后m串加密后的字符,解码之后求n对应每个m的匹配数,很显然的ac自动机 加密过程是先用对应ascii表的标号来代替字符,然后把这些数字转换成8位的二进制,全部连起来,然后每6位算一个数,用二进制算成整数,最后用这些整数来映射给定的表 题解:反解密就好了,要注意细节,很容易Segmentation Fault,最后算出来的字符用int存,然后跑ac自动机就行了 #include<bits/stdc++.h…
病毒侵袭 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 24393    Accepted Submission(s): 5862 Problem Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事…
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3932 题意 给出 N 个人,然后 1-N 然后 从 1 - N 一个一个的进,每个人 进去 都可以在在座的人握手,然后给出那个人握手的次数 要求出 握手次数的最大值 思路 只要进来的人握手次数>=1 那么 本来已经在区域内的人 那个当前这个人的握手次数 就是其给出的握手次数,本来已经在区域内的人握手次数都+1,因为都是有可能的 然后实际发现 ,可以FOR 一遍…
水 Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about hi…
再水一发,舍友肿么还在睡T T. ---------------------------------舍友还在睡觉的分割线--------------------------------- http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3200 大意:给你一串字符串,要求你按'Z''O''J''7'+'其他字符'排好序. 代码不太美观.不过还好啦. 不要像题目说的那样傻傻的排序,直接数个数就可以啦.输出的时候不是那四个字母就输…
Big String Time Limit: 2 Seconds Memory Limit: 65536 KB We will construct an infinitely long string from two short strings: A = "^__^" (four characters), and B = "T.T" (three characters). Repeat the following steps: Concatenate A after…
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3787 思路:结构体 时间转化为秒记录下最小并且排序就好了 /** @Date : 2017-03-23-22.06 * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : */ #include<bits/stdc++.h> #define LL…
Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1727 题目大意: 给你书名.出版时间.价格,让你按照一定的顺序排序.. 其中题目会给出优先级最高的,剩下两个按书名优先级>出版时间>价格来排序. 思路: 练习sort重载的... 不过sort(book,book+n,cmp_by_name);的重载函数竟然不能用引用..不然会cp好吧,我习惯写重载<运算符了. #include<cstdio> #incl…
2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1951 ZOJ:2679先来~ 水题大意:(题目大意:我什么时候改名了哇T T) 给你一个5位数的中间三个字母,还有一个数N让你求能被N整除的最大的五位数. 思路: 直接暴力枚举.... #include<cstdio> int…