【牛客网多校第一场】A】的更多相关文章

题目链接:https://www.nowcoder.com/acm/contest/139/A 题意:大概就是给你0,1,2让你填矩阵问有多少种填法满足 a(i,j)<=a(i+1,j)以及a(i,j)<=a(i,j+1) 题解:Lindström–Gessel–Viennot lemm这个定理的应用. 本鶸也是第一次看见这种东西.去稍微了解了一下.是一个求不相交路径的东西. 给定n个起点,n个终点,不相交路径的方法数的矩阵行列式如下. 其中e(a,b)为图上a到b的方案数. 题解上的ppt给…
A.Equivalent Prefixes 传送门 题意:给你两个数组,求从第一个元素开始到第p个元素 满足任意区间值最小的元素下标相同的 p的最大值. 题解:我们可以从左往右记录到i为止每个区间的最小值有哪些,因为每个值都是不一样的,对于当前的 i 如果1~i中每个区间最小值数量相同那么下标肯定也会相同,否则记录的值的数量就会不同,我们可以用单调栈记录目前为止每个区间的“最小值”的下标,栈里面元素数量不同时肯定不满足条件. 代码: #include <bits/stdc++.h> #defi…
一.题目描述: 链接:https://www.nowcoder.com/acm/contest/139/JGiven a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, r2), ..., (lq, rq), find count(l1, r1), count(l2, r2), ..., count(lq, rq) where count(i, j) is the number of diff…
题意:给你一个数组, q次询问, 每次询问都会有1个[l, r] 求 区间[1,l] 和 [r, n] 中 数字的种类是多少. 解法1, 莫队暴力: 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout); #define L…
题目:https://ac.nowcoder.com/acm/contest/881/H 题意:求一个集合内所有子集异或和为0的长度之和 思路:首先集合内异或和,这是线性基的一个明显标志,然后我们不管怎么样先求出一个基A,秩为r 我们枚举基外的数,每个数的贡献是  2^(n-r-1) ,为什么呢,因为其余数我都可以选择选或不选,无论什么组合,我都可以在基内表示出来,那么就肯定异或为0 我们再来枚举基A内的数,我枚举当前数的时候把其余元素再求一遍基,然后以上面相同的道理计算贡献, #include…
又是一个看起来神奇无比的东东,证明是不可能证明的,这辈子不可能看懂的,知道怎么用就行了,具体看wikihttps://en.wikipedia.org/wiki/Lindstr%C3%B6m%E2%80%93Gessel%E2%80%93Viennot_lemma LGV定理就是求n个起点到n个终点(且一个起点对应一个终点)的不相交路径数目的一种方法,光看这句话不好理解,来看一道cf题 CodeForces - 348D Turtles 这道题给你一个n*m的矩阵(1~n, 1~m),现在有两只…
题目链接 大致题意 有(n+m)(n + m)(n+m)个字母A和(n+m)(n + m)(n+m)个字母B,组成一个长度为 2∗(n+m)2*(n + m)2∗(n+m)的字符串,并且使得字符串中有nnn个"AB"和mmm个"BA",求出可能的组合数(mod 1e9+7) 例如,n = 1 m = 2时,可以有这样的字符串(并不是全部的字符串): ABBABA ABBBAA BBABAA 上面三个字符串均满足条件 解题思路 考虑递推,假设已经有一个字符串满足一定的…
链接:https://www.nowcoder.com/acm/contest/147/E 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Niuniu likes to play OSU! We simplify the game OSU to the following problem. Given n and m, there are n clicks. Each c…
链接:https://www.nowcoder.com/acm/contest/141/C 来源:牛客网 题目描述 Eddy likes to play cards game since there are always lots of randomness in the game. For most of the cards game, the very first step in the game is shuffling the cards. And, mostly the randomn…
链接:https://www.nowcoder.com/acm/contest/141/E 来源:牛客网 题目描述 Eddy likes to play with string which is a sequence of characters. One day, Eddy has played with a string S for a long time and wonders how could make it more enjoyable. Eddy comes up with foll…