CF368 E - Garlands】的更多相关文章

主席树 其实暴力二维树状还更快 #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 <…
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…
re了20多发 还是我在测试数据上操作最后了10多发才发现的 其实只需要多加一句就好了 真的愚蠢啊,要不都能进前100了 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 100005; const int INF = 0x3f3f3f3f; int sh[1005][1005]; int flag[1005]; int sum[1005]; int all; int vis[…
大意: 给定n*m矩阵, k条链, 链上每个点有权值, 每次操作可以关闭或打开一条链或询问一个子矩阵内未关闭的权值和. 关键询问操作比较少, 可以枚举每条链, 暴力算出该条链对每个询问的贡献. 最后再按询问顺序切换链的状态, 只记录打开的链的贡献即可. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #inclu…
题目大意: 给你三个灯,分别以k1秒一次,k2秒一次和k3秒一次的频率闪烁着. 你可以自定义三个灯开启的时间,问是否有一种方案,使得max(k1,k2,k3)秒之后,每秒钟都至少有一盏灯闪烁. 思路: 很显然,当三盏灯频率都大于4秒一次时,不存在答案,那么我们只需要大力讨论4秒以内的情况即可. #include<cstdio> #include<cctype> #include<algorithm> inline int getint() { register char…
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q个操作; 有以下两种类型 ①将第i个连通块里面灯取反 ②询问你(x1,y1)(x2,y2)这个矩形区域内灯的权值的和; [题解] 要用到二维的树状数组; 取反操作只要O(1)就能完成; 即先不管它是什么,取反就是了; 然后在询问的时候,直接用二维树状数组累加; 这里的累加可能是减也可能是加; 也可能…