# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15810 |
2015-07-29T12:00:06 Z |
comet |
빨간 직사각형 (kriii3_QQ) |
C++ |
|
236 ms |
99400 KB |
#include<iostream>
using namespace std;
typedef long long ll;
ll 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');
ll ans=0;
for(int i=1;i<=n;i++){
int sz=0,cnt;
st[sz]=0;
INDEX[sz++]=0;
for(int j=1;j<=m+1;j++){
cnt=0;
while(sz>1&&st[sz-1]>=col[i][j]){
//cout<<"sz= "<<sz<<endl;
ans+=(j-INDEX[sz-2]-1ll)*st[sz-1];
if(cnt){
ans-=(j-INDEX[sz-2]-1ll)*st[sz-1];
ans+=(INDEX[sz-1]-INDEX[sz-2])*st[sz-1]*(j-INDEX[sz-1]);
//ans+=(INDEX[sz-1]-INDEX[sz-2])*(j-INDEX[sz-1]);
}
sz--;
cnt++;
//cout<<"ans= "<<ans<<endl;
}
st[sz]=col[i][j];
INDEX[sz++]=j;
//cout<<j<<" "<<ans<<endl;
}
//cout<<"i= "<<i<<endl;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
99400 KB |
Output is correct |
2 |
Correct |
0 ms |
99400 KB |
Output is correct |
3 |
Correct |
0 ms |
99400 KB |
Output is correct |
4 |
Correct |
0 ms |
99400 KB |
Output is correct |
5 |
Correct |
0 ms |
99400 KB |
Output is correct |
6 |
Correct |
0 ms |
99400 KB |
Output is correct |
7 |
Correct |
0 ms |
99400 KB |
Output is correct |
8 |
Correct |
0 ms |
99400 KB |
Output is correct |
9 |
Correct |
0 ms |
99400 KB |
Output is correct |
10 |
Correct |
0 ms |
99400 KB |
Output is correct |
11 |
Correct |
0 ms |
99400 KB |
Output is correct |
12 |
Correct |
0 ms |
99400 KB |
Output is correct |
13 |
Correct |
0 ms |
99400 KB |
Output is correct |
14 |
Correct |
0 ms |
99400 KB |
Output is correct |
15 |
Correct |
0 ms |
99400 KB |
Output is correct |
16 |
Correct |
0 ms |
99400 KB |
Output is correct |
17 |
Correct |
0 ms |
99400 KB |
Output is correct |
18 |
Correct |
0 ms |
99400 KB |
Output is correct |
19 |
Correct |
0 ms |
99400 KB |
Output is correct |
20 |
Correct |
0 ms |
99400 KB |
Output is correct |
21 |
Correct |
4 ms |
99400 KB |
Output is correct |
22 |
Correct |
5 ms |
99400 KB |
Output is correct |
23 |
Correct |
5 ms |
99400 KB |
Output is correct |
24 |
Correct |
6 ms |
99400 KB |
Output is correct |
25 |
Correct |
4 ms |
99400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
99400 KB |
Output is correct |
2 |
Correct |
0 ms |
99400 KB |
Output is correct |
3 |
Correct |
13 ms |
99400 KB |
Output is correct |
4 |
Correct |
8 ms |
99400 KB |
Output is correct |
5 |
Correct |
13 ms |
99400 KB |
Output is correct |
6 |
Correct |
13 ms |
99400 KB |
Output is correct |
7 |
Correct |
12 ms |
99400 KB |
Output is correct |
8 |
Correct |
13 ms |
99400 KB |
Output is correct |
9 |
Correct |
13 ms |
99400 KB |
Output is correct |
10 |
Correct |
10 ms |
99400 KB |
Output is correct |
11 |
Correct |
16 ms |
99400 KB |
Output is correct |
12 |
Correct |
5 ms |
99400 KB |
Output is correct |
13 |
Correct |
23 ms |
99400 KB |
Output is correct |
14 |
Correct |
0 ms |
99400 KB |
Output is correct |
15 |
Correct |
0 ms |
99400 KB |
Output is correct |
16 |
Correct |
0 ms |
99400 KB |
Output is correct |
17 |
Correct |
6 ms |
99400 KB |
Output is correct |
18 |
Correct |
0 ms |
99400 KB |
Output is correct |
19 |
Correct |
0 ms |
99400 KB |
Output is correct |
20 |
Correct |
0 ms |
99400 KB |
Output is correct |
21 |
Correct |
7 ms |
99400 KB |
Output is correct |
22 |
Correct |
6 ms |
99400 KB |
Output is correct |
23 |
Correct |
6 ms |
99400 KB |
Output is correct |
24 |
Correct |
14 ms |
99400 KB |
Output is correct |
25 |
Correct |
15 ms |
99400 KB |
Output is correct |
26 |
Correct |
5 ms |
99400 KB |
Output is correct |
27 |
Correct |
8 ms |
99400 KB |
Output is correct |
28 |
Correct |
6 ms |
99400 KB |
Output is correct |
29 |
Correct |
6 ms |
99400 KB |
Output is correct |
30 |
Correct |
6 ms |
99400 KB |
Output is correct |
31 |
Correct |
176 ms |
99400 KB |
Output is correct |
32 |
Correct |
160 ms |
99400 KB |
Output is correct |
33 |
Correct |
110 ms |
99400 KB |
Output is correct |
34 |
Correct |
158 ms |
99400 KB |
Output is correct |
35 |
Correct |
159 ms |
99400 KB |
Output is correct |
36 |
Correct |
190 ms |
99400 KB |
Output is correct |
37 |
Correct |
235 ms |
99400 KB |
Output is correct |
38 |
Correct |
210 ms |
99400 KB |
Output is correct |
39 |
Correct |
236 ms |
99400 KB |
Output is correct |
40 |
Correct |
167 ms |
99400 KB |
Output is correct |