题目链接 做出二维\(ST\)表,然后\(O(n^2)\)扫一遍就好了. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 1010; const int MAXLOGN = 12; int Max[MAXN][MAXN][MAXLOGN], Min[MAXN][MAXN][MAXLOGN], Log[MAXN]; int n,
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
~~~题面~~~ 题解: 因为数据范围不大,而且题目要求的是正方形,所以这道题有2种解法. 1,st表. 这种解法暴力好写好理解,但是较慢.我们设st[i][j][k]表示以(i, j)为左端点,向下/向右分别扩展$2^k$格的最大值,最小值同理,处理完后$n^2$枚举左端点取最优值即可. (此为早期代码,写丑了不要介意) #include<bits/stdc++.h> using namespace std; #define R register int #define AC 1010 #d