[CF911C]Three Garlands】的更多相关文章

题目大意: 给你三个灯,分别以k1秒一次,k2秒一次和k3秒一次的频率闪烁着. 你可以自定义三个灯开启的时间,问是否有一种方案,使得max(k1,k2,k3)秒之后,每秒钟都至少有一盏灯闪烁. 思路: 很显然,当三盏灯频率都大于4秒一次时,不存在答案,那么我们只需要大力讨论4秒以内的情况即可. #include<cstdio> #include<cctype> #include<algorithm> inline int getint() { register char…
Garlands 我怎么感觉好水啊. 因为询问只有2000组, 离线询问, 枚举联通块再枚举询问, 二维树状数组更新答案. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int…
E. Garlands 题目连接: http://www.codeforces.com/contest/707/problem/E Description Like all children, Alesha loves New Year celebration. During the celebration he and his whole family dress up the fir-tree. Like all children, Alesha likes to play with gar…
C. Three Garlands time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mi…
题意: n个数分成m段,每段偶数个数,最小化和最大段的半个区间的数字和. 分析: 先想到了二分,dp求能分成的最小段数. #include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <cstdio> #include <vector> #include <…
题目链接:http://codeforces.com/problemset/problem/707/E 给你nxm的网格,有k条链,每条链上有len个节点,每个节点有一个值. 有q个操作,操作ask问你一个子矩阵的和是多少,操作switch将第i条链上的值0变原来的数or原来的数变0. 比较明显的二维数组数组暴力,注意的是ask操作不会超过2000,所以在switch操作的时候不能进行update操作,否则会超时.所以你在ask操作的时候update就会省时. 复杂度大概是2000*2000*l…
主席树 其实暴力二维树状还更快 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 2005; int N,M,K,Q; struct Node{ int x,y,w; Node(int a=0, int b=0, int c=0):x(a),y(b),w(c){} bool operator < (Node T) { if(x != T.x) return x <…
大意: 给定n*m矩阵, k条链, 链上每个点有权值, 每次操作可以关闭或打开一条链或询问一个子矩阵内未关闭的权值和. 关键询问操作比较少, 可以枚举每条链, 暴力算出该条链对每个询问的贡献. 最后再按询问顺序切换链的状态, 只记录打开的链的贡献即可. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #inclu…
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q个操作; 有以下两种类型 ①将第i个连通块里面灯取反 ②询问你(x1,y1)(x2,y2)这个矩形区域内灯的权值的和; [题解] 要用到二维的树状数组; 取反操作只要O(1)就能完成; 即先不管它是什么,取反就是了; 然后在询问的时候,直接用二维树状数组累加; 这里的累加可能是减也可能是加; 也可能…
题目链接:http://codeforces.com/contest/707/problem/A A. Brain's Photos time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Small, but very brave, mouse Brain was not accepted to summer school of y…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
A. Nearest Minimums time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array of n integer numbers a0, a1, ..., an - 1. Find the distance between two closest (nearest) minimum…
As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent New Year Tree must be decorated with a good garland. Edward has lamps of m colors and he wants to mak…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' - colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
B. Two Cakes 传送门:http://codeforces.com/contest/911/problem/B 本题是一个数学问题. 有a个Ⅰ类球,b个Ⅱ类球:有n个盒子.将球放入盒子中,要求: ①所有的球均被放入盒子中: ②每一个盒子中至少有一个球: ③一个盒子里至多只能有一类球. 设将所有的球放入盒子后,每个盒子里至少有x个球.求x的最大值. 由上述规则可知,一个盒子或放入Ⅰ类球,或放入Ⅱ类球.设放入Ⅰ类球的盒子数为i,放入Ⅱ类球的盒子数为j,则:i+j=n. 于是,为使盒子中放入…
Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion Counting 先算出来最初逆序对个数,对于每次选择,如果选出的区间里数对个数为偶数个,则其中正序对和逆序对个数可能分别为(奇数+奇数)或(偶数+偶数),此时总的逆序对奇偶性不变:如果选出的区间里数对个数为奇数个,则其中正序对和逆序对个数可能分别为(奇数+偶数)或(偶数+奇数),此时总的逆序对奇偶性…
A. New Year Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood,…
But, first, as it was important to know how numerous those pestilent Danes were, and how they were fortified, King Alfred, being a good musician, disguised himself as a glee-man or minstrel, and went, with his harp, to the Danish camp. He played and…