Submission #15561

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