ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number i and col…
Codeforces 题目传送门 & 洛谷题目传送门 下设 \(n,m\) 同阶. 首先有一个傻子都会的暴力做法,枚举矩形的上.下边界 \(l,r\),考虑集合多重集 \(S=\{y|x\in[l,r],(x,y)\text{为标记点}\}\),也就是所有在第 \(l\) 行与第 \(r\) 行之间所有标记点的列坐标的集合,考虑进一步枚举矩形的左端点 \(x\),那么对于右端点 \(y\),以 \((l,x)\) 为左上角,\((r,y)\) 为右下角的矩形中至少有 \(k\) 个标记点当前仅当…
原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每个区间的和都为0.对于每个区间来说,设该区间长度为l,则让该区间都为0的操作数为l-1,例如:1 .1 .-3 .1的操作数为3,也就是说,若把a分成k个区间,则a所需要的总的操作数为n-k. 所以现在我们的目标就是把数组a划分为尽可能多的部分,这个时候我们可以用一个map,统计前缀和的个数,因为对…
题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these…
D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a regular polygon with nn vertices labeled from 11 to nn in counter-clockwise order. The triangulatio…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeForces - 215C - Crosses(思维题) C:CF–思维练习–CodeForces - 216C - Hiring Staff (思维+模拟) D:CF思维联系–CodeForces-217C C. Formurosa(这题鸽了) E:CF思维联系–CodeForces - 218C E…
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
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',…