题目链接: B. Nanami's Digital Board time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nanami is an expert at playing games. This day, Nanami's good friend Hajime invited her to watch a game of ba…
B. Nanami's Digital Board 题目连接: http://www.codeforces.com/contest/434/problem/B Description Nanami is an expert at playing games. This day, Nanami's good friend Hajime invited her to watch a game of baseball. Unwilling as she was, she followed him to…
大意: 给定01矩阵, m个操作, 操作1翻转一个点, 操作2求边界包含给定点的最大全1子矩阵 暴力枚举矩形高度, 双指针统计答案 #include <iostream> #include <algorithm> #include <math.h> #include <cstdio> #include <set> #include <map> #include <string> #include <vector>…
题意: 给出点(x1,y1),求以x=x1为上边界,或下边界:以y=y1为左边界,或右边界矩形的最大值(矩形内所有的点均为1) 定义四个数组lft[][],rht[][],up[][],down[][] 在up[x][y]中存的是 点(x,y)的上边有多少个连续的1 其他同理: 在确定最大的矩形时,用到了枚举法,go函数: 代码参考自:vjudge2 代码风格:思路清晰,代码明了 #include<stdio.h> #include<string.h> #include<al…
题目连接 题意: 给n*m的0/1矩阵,q次操作,每次有两种:1)将x,y位置值翻转 2)计算以(x,y)为边界的矩形的面积最大值 (1 ≤ n, m, q ≤ 1000) 分析: 考虑以(x,y)为下边界的情况,h=(x,y)上边最多的连续1的个数.那么递减的枚举,对于当前hx,仅仅须要看两側能到达的最远距离,使得h(x,ty)不大于h就可以.之后的枚举得到的两側距离大于等于之前的,所以继续之前的两側距离继续枚举就可以. const int maxn = 1100; int n, m, q;…
q次询问,每次询问能够对矩阵某一个值改变(0变1.1变0) 或者是查询子矩阵的最大面积,要求这个这个点在所求子矩阵的边界上,且子矩阵各店中全为1 用up[i][j]表示(i,j)这个点向上能走到的最长高度  若(i,j)为0 则up[i][j]值为0 同理.维护down,left, right数组 则每次查询时.从up[i][j]枚举至1作为子矩阵的高度,然后途中分别向左右扩展.若up[i][j - 1] >= up[i][j],则可向左扩展一个单位,答案为(r - l - 1) * 高度 同理…
链接:https://codeforces.com/contest/161/problem/D 题意:给一个树,求距离恰好为$k$的点对是多少 题解:对于一个树,距离为$k$的点对要么经过根节点,要么跨过子树的根节点,于是考虑树分治 用类似poj1741的想法,可以推出: 对于任意一棵子树,其根节点记为$C$,其子树中: 记距离$C$距离之和为$k$的点对数量$S_{c}$ 记$C$儿子节点$C_1...C_n$的子树中,距离$C_i$距离为$k-2$的点对数量为$S'_{c_i}$ 其符合条件…
Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Naturally the zoo is connected, so…
C. Digital Root 题目连接: http://www.codeforces.com/contest/10/problem/C Description Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equat…
Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Polycarp decided to rewatch his absolute favourite epi…