Submission #15560

#TimeUsernameProblemLanguageResultExecution timeMemory
15560Fakeable빨간 직사각형 (kriii3_QQ)C++98
0 / 20
0 ms6692 KiB
#include<iostream> #include<algorithm> #include<memory.h> #include<stack> #include<utility> using namespace std; const int max_n = 1010; int n,m,h[max_n][max_n]; long long ans; char a[max_n][max_n]; int main() { ios_base::sync_with_stdio(false); cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<m;i++) if(a[0][i]=='R') h[0][i] = 1; for(int i=1;i<n;i++) { for(int j=0;j<m;j++) { if(a[i][j] == 'R') h[i][j] = h[i-1][j]+1; } } for(int i=0;i<n;i++) { stack<pair<int,int> > s; s.push(make_pair(-1,-1)); for(int j=0;j<m;j++) { pair<int,int> now = make_pair(j,h[i][j]); while(1) { pair<int,int> T = s.top(); if(T.second >= now.second) s.pop(); else break; } int width = j-s.top().first; ans += 1LL * width * now.second; s.push(now); } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...