이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |