Chinese questions, test instructions not much to say.
It felt like DP.
In fact, as long as the maintenance of monotony from top to bottom is good
The Pit is ... This OJ ... With Cin it is easy to tle ...
1 //#include <bits/stdc++.h>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <cctype>6#include <climits>7#include <iostream>8#include <algorithm>9#include <cmath>Ten using namespacestd; OnetypedefLong LongLL; A#include <queue> - - structnode the { - intVal, CNT; -}s[2005]; - intval[2005][2005]; + Charmp[2005][2005]; - intMain () + { A intN, M; at while(~SCANF ("%d%d", &n, &m)) - { - //memset (val, 0, sizeof (Val)); - for(intI=1; i<=n;i++) - { -val[i][0]=0; inscanf"%s", mp[i]+1); - for(intj=1; j<=m;j++) to { + //cin>>mp[i][j]; -Val[i][j]= (mp[i][j]=='W')? (val[i][j-1]+1):0; the } * } $LL ans=0;Panax Notoginseng for(intj=1; j<=m;j++) - { theLL sum=0; + intHead=0; A for(intI=1; i<=n;i++) the { + node T; -T.VAL=VAL[I][J], t.cnt=1; $ while(Head && t.val<=s[head-1].val) $ { -head--; -sum-=s[head].val*1ll*s[head].cnt; thet.cnt+=s[head].cnt; - }Wuyisum+=t.val*1ll*t.cnt; thes[head++]=T; -ans+=sum; Wu } - } Aboutprintf"%i64d\n", ans); $ } - return 0; -}
Fzu 2190
Record (I, j) the number of contiguous watts in front of Val[i][j]
Maintain The Matrix (I, j) to the lower right
"Miscellaneous questions" FZUU2190 The redemption of non-mention