"Miscellaneous questions" FZUU2190 The redemption of non-mention

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.