2场 J -Subarray】的更多相关文章

题意: 长度为1e91e9的(1,−1)(1,−1)序列,下标从00到1e9−11e9−1,已知有nn个区间为11,其他为−1−1, 问存在多少个区间的和>1>1(保证∑1≤i≤nr[i]−l[i]+1≤1e7∑1≤i≤nr[i]−l[i]+1≤1e7). 给你一个n 表示有n段连续的1序列 现在问你 在总长度为0~1e9-1的范围内有多少个大于0的子段. 题解 可能作为区间端点的点个数最多为3e73e7 f[i]表示以第ii个区间右端点为答案右端点的最大区间和 g[i]表示以第ii个区间左端…
牛客多校第3场 J 思维+树状数组+二分 传送门:https://ac.nowcoder.com/acm/contest/883/J 题意: 给你q个询问,和一个队列容量f 询问有两种操作: 0.访问操作,如果询问的name在队列中存在的话,那么就输出队列中name对应的val值,然后将队列中name对应的元素扔到队列的尾部去,否则就直接将该元素插入到队列的尾部去 1.插入操作,得到队列中对应的name元素的v值为k,查询第k+v个元素的v值是多少 题解: 已知,对于插入操作,我们需要很快的查询…
题意:给你一个n 表示有n段连续的1序列 现在问你 在总长度为0~1e9-1的范围内有多少个大于0的子段 思路:假设我们统计了当前的前缀和 我们显然可以用树状数组维护一下前缀和 这样我们可以nlogn算出答案 但是对于1e7的数据 这样处理肯定会超时 所以我们考虑前缀和是一个每次变化都是1的折线 我们可以直接数组模拟lazy来求出答案 #include <bits/stdc++.h> using namespace std; ; const int inf = 0x3f3f3f3f; type…
题目链接 题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的那个去做,问她最终有一个账号达到1000分需要做的比赛的次数的期望值. 思路 :可以直接用公式推出来用DP做,也可以列出210个方程组用高斯消元去做. (1)DP1:离散化.因为50,100,1000都是50的倍数,所以就看作1,2,20.这样做起来比较方便. 定义dp[i]为从 i 分数到达i+1…
这是一道5Y的题目 有坑的地方我已在代码中注释好了 QAQ Ps:模拟题还是练的太少了,速度不够快诶 //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <climits> #include <cstring> #include <cmath> #inclu…
题意很简单,就是两个大矩阵相乘,然后求乘积. 用 Strassen算法 的话,当N的规模达到100左右就会StackOverFlow了 况且输入的数据范围可达到800,如果变量还不用全局变量的话连内存开辟都开不出来 #pragma comment(linker, "/STACK:16777216") #include <iostream> #include <stdio.h> #define ll long long using namespace std; ;…
Problem J. Let Sudoku Rotate Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Sudoku is a logic-based, combinatorial number-placement puzzle, which is popular around the w…
White Rabbit has a rectangular farmland of n*m. In each of the grid there is a kind of plant. The plant in the j-th column of the i-th row belongs the a[i][j]-th type.White Cloud wants to help White Rabbit fertilize plants, but the i-th plant can onl…
题目链接: https://www.nowcoder.com/acm/contest/140/J 思路: 都写在代码注释里了,非常好懂.. for_each函数可以去看一下,遍历起vector数组比较方便,用for(int i = 0;i < q[i].size();i++)的话,是会有一些弊端的,虽然对于这道题应该没什么影响,但最好规范下. 耗时:2072ms 实现代码: #include<bits/stdc++.h> using namespace std; ; vector<…
链接:https://www.nowcoder.com/acm/contest/143/J 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 There are n students going to travel. And hotel has two types room:double room and triple room. The price of a double…