牛客多校第四场 A Ternary String】的更多相关文章

题目描述 A ternary string is a sequence of digits, where each digit is either 0, 1, or 2. Chiaki has a ternary string s which can self-reproduce. Every second, a digit 0 is inserted after every 1 in the string, and then a digit 1 is inserted after every…
牛客多校第四场sequence C (线段树+单调栈) 传送门:https://ac.nowcoder.com/acm/contest/884/C 题意: 求一个$\max {1 \leq l \leq r \leq n}\left{\min \left(a{l \dots r}\right) \times \operatorname{sum}\left(b_{l \dots r}\right)\right} $ 题解: 枚举最小值 最大值可能有两种情况:两个正数相乘,两个负数相乘,我们先讨论正…
链接:https://www.nowcoder.com/acm/contest/142/F来源:牛客网 题目描述 There's a beautiful garden whose size is n x m in Chiaki's house. The garden can be partitioned into n x m equal-sized square chunks. There are some kinds of flowers planted in each square chun…
链接:https://www.nowcoder.com/acm/contest/142/G来源:牛客网 The mode of an integer sequence is the value that appears most often. Chiaki has n integers a1,a2,...,an. She woud like to delete exactly m of them such that: the rest integers have only one mode an…
目录 求若干个串的公共子串个数相关变形题 对一个串建后缀自动机,另一个串在上面跑同时计数 广义后缀自动机 后缀数组 其他:POJ 3415 求两个串长度至少为k的公共子串数量 @(牛客多校第四场 I题 string) 求若干个串的公共子串个数相关变形题 牛客这题题意大概是求一个长度为\(2e5\)的字符串有多少个不同子串,若\(s==t\)或\(s==rev(t)\)则认为子串\(s,t\)相同.我们知道回文串肯定和他的反串相同. 链接:传送门. 做法1: \(yx\)大佬秒出思路%%,对\(s…
链接:https://ac.nowcoder.com/acm/contest/884/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 A new city has just been built. There're nnn interesting places numbered by positive numbers from 111 to nnn. In order…
题目链接 传送门 题意 给你\(n\)个基底,求\([l,r]\)内的每个基底是否都能异或出\(x\). 思路 线性基交板子题,但是一直没看懂咋求,先偷一份咖啡鸡板子写篇博客吧~ 线性基交学习博客:传送门 代码实现如下 #include <set> #include <map> #include <deque> #include <queue> #include <stack> #include <cmath> #include &l…
题目传送门:https://www.nowcoder.com/acm/contest/142/J 题意:给一个hash table,求出字典序最小的插入序列,或者判断不合法. 分析: eg.对于序列{7,8,16},插入后为{16, -1, -1, -1, -1, -1, -1, 7, 8}.(即,依次插入7,8,16.而插入16时发现7已经被占,所以依次考虑(h(x)+1)%n ,因此16放在0的位置上.)这是正向插入,问题是给一个最终序列,问插入序列. 通过对hash表的观察可以得到: 一个…
题意: 给出一个已知的哈希表.求字典序最小的插入序列,哈希表不合法则输出-1. 题解: 对于哈希表的每一个不为-1的数,假如他的位置是t,令s = a[t]%n.则这个数可以被插入当且仅当第s ~ t-1个数都不为-1且已经插入完成. 那么对于每一个这样的数,需要连t-s条边(s<=t)或者t+n-s条边(s>t). 总的边数有O(n^2)条.可以用线段树优化建图.最后跑一边拓扑排序. 对于不合法的情况,第s ~ t-1个数存在-1或者拓扑图存在环会导致不合法. #include <bi…
题意 给你 $n$ 个集合,每个集合中包含一些整数.我们说一个集合表示一个整数当且仅当存在一个子集其异或和等于这个整数.现在你需要回答 $m$ 次询问 ($l, r, x$),是否 $l$ 到 $r$ 的每个集合都能表示 $x$. 分析 先求出每个集合的线性基,然后用线段树维护线性基的交,详见代码 #include<bits/stdc++.h> #define reg register using namespace std; typedef long long ll; ; + ; int n…