Submission #15808

# Submission time Handle Problem Language Result Execution time Memory
15808 2015-07-29T11:35:52 Z comet 빨간 직사각형 (kriii3_QQ) C++
0 / 20
0 ms 55976 KB
#include<iostream>
using namespace std;
int n,m,col[3333][3333],st[3333],INDEX[3333];
char a[3333][3333];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>&a[i][1];

	for(int j=1;j<=m;j++)
		for(int i=1;i<=n;i++)
			if(a[i][j]=='R')col[i][j]=col[i-1][j]+(a[i][j]=='R');

	int ans=0;
	for(int i=1;i<=n;i++){
		int sz=0;
		st[sz]=0;
		INDEX[sz++]=0;
		for(int j=1;j<=m+1;j++){
			while(sz>1&&st[sz-1]>=col[i][j]){
				ans+=(j-INDEX[sz-2]-1)*st[sz-1];
				sz--;
			}
			st[sz]=col[i][j];
			INDEX[sz++]=j;
		}
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 55976 KB Output is correct
2 Incorrect 0 ms 55976 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -