Submission #15075

#TimeUsernameProblemLanguageResultExecution timeMemory
15075gs14004빨간 직사각형 (kriii3_QQ)C++14
20 / 20
284 ms1596 KiB
#include <cstdio> #include <stack> using namespace std; int height[3005]; char str[3005]; int n, m; long long ret; int main(){ scanf("%d %d",&n,&m); for(int i=1; i<=n; i++){ scanf("%s",str + 1); stack<int> hi, pos, area; hi.push(0); pos.push(0); area.push(0); for(int j=1; j<=m; j++){ if(str[j] == 'R') height[j]++; else height[j] = 0; while(!hi.empty() && hi.top() > height[j]){ hi.pop(); area.pop(); pos.pop(); } area.push(area.top() + (j - pos.top()) * height[j]); pos.push(j); hi.push(height[j]); ret += area.top(); } } printf("%lld",ret); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...