B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/B Description Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he…
B. Wilbur and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one…
E. Wilbur and Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/E Description Wilbur the pig now wants to play with strings. He has found an n by m table consisting only of the digits from 0 to 9 where the…
D. Wilbur and Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/D Description Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. The…
C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/C Description Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if…
A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/A Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his back…
C. Wilbur and Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Mor…
A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in…
水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int main(void) { int n, x[4], y[4]; cin >> n; for (int i=0; i<n; +…
A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in…
http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG…
A. Greg and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/295/problem/A Description Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 ≤ li ≤ ri ≤ n). To apply operation …
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把下降段的起始位置和结束位置记录下来然后进行推断,在进行推断时,有几种特殊情况:(s表示起始位置,e表示结束位置) 1.当e==n&&s!=1时,满足a[n]>a[s-1]输出yes: 2当s==1&&==n时,满足a[1]<a[e+1] 输出yes: 3当s==1&…
http://codeforces.com/contest/1042/problem/D 题意 给一个数组n个元素,求有多少个连续的子序列的和<t (1<=n<=200000,abs(a[i])<=1e9) 思路 将公式转化以下,sum[r]-sum[l-1]<t 变成 sum[r]<sum[l-1]+t 可以考虑遍历每个r,先更新sum[r-1]+t,统计有多少满足条件的sum[l-1],反向树状数组维护即可 实现细节 对于每个r是更新他的sum[r-1] 因为要统计…
D. Maxim and Array 题目连接: http://codeforces.com/contest/721/problem/D Description Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or…
E. Sasha and Array 题目连接: http://codeforces.com/contest/719/problem/E Description Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r x - increase all integers on the segment from l…
http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的数,只要有一个不为0的数,那么就能分割. 如果一个数不为0,则让它单独成为一组,如果它后面有0,则把它后面的连续的0也归到这一组中. 特别要注意一下的是,序列一开始就是0的情况. #include<iostream> #include<algorithm> #include<cs…
D. Petya and Array 题目链接:https://codeforces.com/contest/1042/problem/D 题意: 给出n个数,问一共有多少个区间,满足区间和小于t. 题解: 假设目前区间右端点为r,左端点为l,那么由前缀和可得知:sumr-suml-1<t,然后我们再边个形:sumr<t+suml-1,根据这个我们可以发现这有点类似于逆序对. 然后我们就可以用求解逆序对问题的解法来解这个问题了,这里不同的就是每次前面的加上t大于当前这个数即为一对逆序对. 我用…
题目链接:http://codeforces.com/problemset/problem/721/D D. Maxim and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Maxim has found an array of n integers, needed by no one. He…
Bryce1010模板 http://codeforces.com/contest/1008/problems #include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN=1e5+10; const int INF=0x3f3f3f3f; int a[MAXN]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin…
题目链接:http://codeforces.com/contest/451/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma…
[Link]:http://codeforces.com/contest/831/problem/A [Description] 让你判断一个数列是不是这样一个数列: 一开始是严格上升 然后开始全都是一个数字 然后又开始严格下降 [Solution] 枚举中间全部相同的是哪个数字; 假设是i..j这一段 则看看1..i是不是严格上升,以及j+1..n是不是严格下降; 如果所有的这样的i..j都不满足则无解; 找到一组则有解; [NumberOf WA] 0 [Reviw] 找到最特殊的地方: 抓…
链接: https://codeforces.com/contest/1180/problem/B 题意: Nick had received an awesome array of integers a=[a1,a2,-,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disapp…
传送门 分析:其实没什么好分析的.统计一下负数个数.如果负数个数是偶数的话,就要尽量增加负数或者减少负数.是奇数的话就努力增大每个数的绝对值.用一个优先队列搞一下就行了. 我感觉这道题的细节极为多,非常复杂,其实是自己智障了.. 我看了一下学长菊苣的代码,好精巧...注释部分是他的代码 /*****************************************************/ //#pragma comment(linker, "/STACK:1024000000,10240…
题目链接 分析:矩阵快速幂+线段树 斐波那契数列的计算是矩阵快速幂的模板题,这个也没什么很多好解释的,学了矩阵快速幂应该就知道的东西= =这道题比较巧妙的在于需要用线段树来维护矩阵,达到快速查询区间斐波那契数列和的目的.这道题极为卡常数,我TLE了不知道多少发,才在赛后过了这道题. 我尝试下来,发现矩阵乘法的写法极为重要,我就是因为用了三层循环来写矩阵乘法导致了悲剧的TLE,一直卡在了第17组数据.我百度了网上别的矩阵快速幂的写法才过了这道题. 还有涨智识的地方是不要随意memset.我原来的矩…
题目链接 线段树的逆过程,想了老一会,然后发现应该是包含区间对存在有影响,就不知怎么做了...然后尚大神,说,So easy,你要倒着来,然后再正着来,判断是不是合法就行了.然后我乱写了写,就过了.数据难道又水了... #include <stdio.h> #include <string.h> #include <iostream> #include <queue> #include <algorithm> using namespace st…
解题报告 http://blog.csdn.net/juncoder/article/details/38102391 对于给定的数组,取对数组中的一段进行翻转,问翻转后是否是递增有序的. 思路: 仅仅要找到最初递减的区域,记录区域内最大和最小的值,和区间位置. 然后把最大值与区间的下一个元素对照,最小值与区间上一个元素对照. 这样还不够,可能会出现两个或两个以上的递减区间,这样的情况直接pass,由于仅仅能翻转一次. #include <iostream> #include <cstd…
D. Maxim and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he in…
E. Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r…
B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distin…