标签:bsp main 单调栈 printf out ble hdu namespace scan
#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 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; const double EPS = 1.0e-8; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; const int maxn = 2e5 + 100; const int maxm = 300; //next_permutation //priority_queue<int, vector<int>, greater<int>> que; int n, m; int num[1005][1005]; int r[1005][1005], l[1005][1005]; void pf() { cout<<endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cout << num[i][j] << " "; } cout << endl; } cout<<endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cout << l[i][j] << " "; } cout << endl; } cout<<endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cout << r[i][j] << " "; } cout << endl; } } char a[10]; int main() { //freopen("bonuses.in", "r", stdin); //freopen("out.txt", "w", stdout); int t; cin >> t; while (t--) { int ans = 0; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { scanf("%s", a); num[i][j] = a[0] == ‘R‘ ? 0 : (num[i - 1][j] + 1); } //pf(); int lenr, lenc; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { l[i][j] = r[i][j] = j; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int cur = j; while (cur != 1 && num[i][cur-1] >= num[i][j]) { cur = l[i][cur - 1]; } l[i][j] = cur; } for (int j = m; j >= 1; j--) { int cnt = j; while (cnt != m && num[i][cnt+1] >= num[i][j]) { cnt = r[i][cnt + 1]; } r[i][j] = cnt; } for(int j=1;j<=m;j++) ans = max(ans, (r[i][j] - l[i][j] + 1) * num[i][j] * 3); } //pf(); cout << ans << endl; } }
标签:bsp main 单调栈 printf out ble hdu namespace scan
原文地址:http://www.cnblogs.com/Aragaki/p/7623957.html