Codeforces 713D Animals and Puzzle】的更多相关文章

题目链接 Animals and Puzzle 题意  给出一个1e3 * 1e3的01矩阵,给出t个询问,每个询问形如x1,y1,x2,y2 你需要回答在以$(x1, y1)$为左上角,$(x1, y2)$为右下角的子矩阵中,最大的全1正方形的边长. 首先考虑DP预处理. $f[i][j]$表示以$f[i][j]$为右下角的最大的全1正方形的边长. 则$f[i][j] = min(f[i - 1][j], f[i][j - 1], f[i - 1][j - 1]) + 1$ 我们对$f[i][…
题意:一个n*m的01矩阵,Q个询问,每次询问一个矩形区域内,最大的全1正方形的边长是多少? 题解:dp[0][0][i][j]表示以(i, j)为右下角的正方形的最长边长.RMQ后,二分答案即可. #include <cstdio> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; ; int x1, y1, x2, y2, n, m; int a[N…
D. Animals and Puzzle 题目连接: http://codeforces.com/contest/713/problem/D Description Owl Sonya gave a huge lake puzzle of size n × m to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turn…
[题目]D. Animals and Puzzle [题意]给定n*m的01矩阵,Q次询问某个子矩阵内的最大正方形全1子矩阵边长.n,m<=1000,Q<=10^6. [算法]动态规划DP+二维ST表 [题解]设f[i][j]为以(i,j)为右下角的最大正方形全1子矩阵. f[i][j]=min{ f[i-1][j-1] , f[i][j-1] , f[i-1][j] }+1 然后用二维ST表处理f[i][j]的子矩阵最小值. 对于每次询问,二分边长x,答案即子矩阵(x1+x-1,y1+x-1…
D - Animals and Puzzle #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; + ; cons…
Animals and Puzzle time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output Owl Sonya gave a huge lake puzzle of size n × m to hedgehog Filya as a birthday present. Friends immediately started to a…
题目链接 给一个01矩阵, 然后每个询问给出两个坐标(x1, y1), (x2, y2). 问你这个范围内的最大全1正方形的边长是多少. 我们dp算出以i, j为右下角的正方形边长最大值. 然后用二维st表预处理出所有的最大值. 对于每个询问, 我们二分一个值mid, 查询(x1 + mid -1, y1 + mid -1), (x2, y2)这个范围内的最大值是否大于mid .如果大于的话就说明在(x1, y1), (x2, y2)范围内存在一个边长为mid的正方形. #include <bi…
G - Animals Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 35D Description input input.txt output output.txt Once upon a time DravDe, an outstanding person famous for his professional ac…
题目链接 Dasha and Puzzle 对于无解的情况:若存在一个点入度大于4,那么直接判断无解. 从根结点出发(假设根结点的深度为0), 深度为0的节点到深度为1的节点的这些边长度为2^30, 深度为1的节点到深度为2的节点的这些边的长度为2^29, ……………………………………………………………… 以此类推. 因为结点个数最多只有30个,所以长度分配足够. #include <bits/stdc++.h> using namespace std; #define REP(i,n) fo…
D. Animals time limit per test 2 seconds memory limit per test 64 megabytes input input.txt output output.txt Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse stori…