#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
llo mod=1000000007;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
//setIO("");
llo n,m;
cin>>n>>m;
char ss;
llo it[n][m];
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
cin>>ss;
if(ss=='J'){
it[i][j]=0;
}
else if(ss=='O'){
it[i][j]=1;
}
else{
it[i][j]=2;
}
}
}
llo pre[n][m];
for(llo i=0;i<n;i++){
for(llo j=m-1;j>=0;j--){
llo cc=0;
if(it[i][j]==1){
cc=1;
}
pre[i][j]=cc;
if(j<m-1){
pre[i][j]+=pre[i][j+1];
}
}
}
llo pre2[n][m];
for(llo j=0;j<m;j++){
for(llo i=n-1;i>=0;i--){
llo cc=0;
if(it[i][j]==2){
cc=1;
}
pre2[i][j]=cc;
if(i<n-1){
pre2[i][j]+=pre2[i+1][j];
}
}
}
llo tot=0;
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
if(it[i][j]==0){
tot+=pre[i][j]*pre2[i][j];
}
}
}
cout<<tot<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
14 |
Correct |
14 ms |
4992 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
9 ms |
3456 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
18 ms |
6392 KB |
Output is correct |
19 |
Correct |
17 ms |
6144 KB |
Output is correct |
20 |
Correct |
14 ms |
6400 KB |
Output is correct |
21 |
Correct |
20 ms |
6528 KB |
Output is correct |
22 |
Correct |
16 ms |
6144 KB |
Output is correct |
23 |
Correct |
15 ms |
6272 KB |
Output is correct |
24 |
Correct |
16 ms |
6400 KB |
Output is correct |
25 |
Correct |
13 ms |
6144 KB |
Output is correct |
26 |
Correct |
14 ms |
6272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
14 |
Correct |
14 ms |
4992 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
9 ms |
3456 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
18 ms |
6392 KB |
Output is correct |
19 |
Correct |
17 ms |
6144 KB |
Output is correct |
20 |
Correct |
14 ms |
6400 KB |
Output is correct |
21 |
Correct |
20 ms |
6528 KB |
Output is correct |
22 |
Correct |
16 ms |
6144 KB |
Output is correct |
23 |
Correct |
15 ms |
6272 KB |
Output is correct |
24 |
Correct |
16 ms |
6400 KB |
Output is correct |
25 |
Correct |
13 ms |
6144 KB |
Output is correct |
26 |
Correct |
14 ms |
6272 KB |
Output is correct |
27 |
Correct |
602 ms |
208248 KB |
Output is correct |
28 |
Correct |
5 ms |
896 KB |
Output is correct |
29 |
Correct |
28 ms |
16256 KB |
Output is correct |
30 |
Correct |
6 ms |
896 KB |
Output is correct |
31 |
Correct |
439 ms |
153208 KB |
Output is correct |
32 |
Correct |
526 ms |
219128 KB |
Output is correct |
33 |
Correct |
483 ms |
219804 KB |
Output is correct |
34 |
Correct |
495 ms |
177656 KB |
Output is correct |
35 |
Correct |
546 ms |
219000 KB |
Output is correct |
36 |
Correct |
504 ms |
219768 KB |
Output is correct |
37 |
Correct |
628 ms |
220536 KB |
Output is correct |
38 |
Correct |
348 ms |
151928 KB |
Output is correct |
39 |
Correct |
340 ms |
152788 KB |
Output is correct |