●CodeForces 480E Parking Lot】的更多相关文章

题链: http://codeforces.com/problemset/problem/480/E题解: 单调队列,逆向思维 (在线的话应该是分治做,但是好麻烦..) 离线操作,逆向考虑, 最后的状态可以用O(N*M)的dp得出最大正方形边长. 然后反向一个一个的把障碍变回非障碍,显然答案不会变小. 维护好up[i][j],down[i][j],分别表示从(i,j)位置向上向下有多长的连续非障碍. 不难发现,如果有更大的答案的话,那么必然包含当前改变的位置的那一行的某些格子. 所以确定了在这一…
大意: 给定01矩阵, 单点赋值为1, 求最大全0正方形. 将询问倒序处理, 那么答案一定是递增的, 最多增长$O(n)$次, 对于每次操作暴力判断答案是否增长即可, 也就是说转化为判断是否存在一个边长$x$的正方形包含给定点, 可以维护左右两侧第一个1的位置, 从上往下滑动窗口即可$O(n)$判断, 总复杂度$O(n^2)$ #include <iostream> #include <algorithm> #include <cstdio> #include <…
传送门 D. Parking Lot time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street…
Parking Lot 线段树区间合并一下, 求当前要占的位置, 不包括两端点的写起来方便一点. #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, int> #de…
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取模. 因为取模后至少减半, 复杂度$O(nlognlogC)$ 2. CF 431E Chemistry Experiment 大意: n个试管, 第$i$个试管有$a_i$单位水银, m个操作: 1, 修改$a_x$改为$v$. 2, 将$v$单位水倒入试管, 求一种方案使得有水的试管水银与水总量的最大…
E. Parking Lot time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A parking lot in the City consists of n parking spaces, standing in a line. The parking spaces are numbered from 1 to n from…
E. Parking Lot time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Petya's been bored at work and he is killing the time by watching the parking lot at the office. The parking lot looks from a…
http://codeforces.com/problemset/problem/630/I 简单的排列组合,推式子技巧:举一个小样例,看着推,别抽象着推,容易错 #include <iostream> #include <cstdio> #include <queue> #include <algorithm> #include <cmath> #include <cstring> #define inf 2147483647 #d…
A. Straight «A» 题面 Noora is a student of one famous high school. It's her final year in school - she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one. In school, w…
CF 480 E. Parking Lot http://codeforces.com/contest/480/problem/E 题意: 给一个n*m的01矩阵,每次可以将一个0修改为1,求最大全0的矩阵. 分析: 将询问离线,从后往前处理询问,相当于每次将一个1变成0,答案是递增的. 用悬线法或者单调栈来求. 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<cmath>…