#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=3e3+5;
int n, m, a[nx][nx], r[nx][nx][3], c[nx][nx][3];
ll ans=0;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for(int i = 1; i <= n; i++)
{
string s;
cin>>s;
for(int j = 1; j <= m; j++)
{
if(s[j-1]=='J')
a[i][j]=0;
else if(s[j-1]=='O')
a[i][j]=1;
else a[i][j]=2;
for(int k = 0; k < 3; k++)
{
r[i][j][k]=r[i-1][j][k]+(a[i][j]==k);
c[i][j][k]=c[i][j-1][k]+(a[i][j]==k);
}
}
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
if(a[i][j]==0)
ans+=(r[n][j][2]-r[i][j][2])*(c[i][m][1]-c[i][j][1]);
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7004 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7004 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7000 KB |
Output is correct |
13 |
Correct |
1 ms |
7004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7004 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7004 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7000 KB |
Output is correct |
13 |
Correct |
1 ms |
7004 KB |
Output is correct |
14 |
Correct |
9 ms |
25948 KB |
Output is correct |
15 |
Correct |
3 ms |
22620 KB |
Output is correct |
16 |
Correct |
5 ms |
19032 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
8 ms |
29788 KB |
Output is correct |
19 |
Correct |
6 ms |
28252 KB |
Output is correct |
20 |
Correct |
6 ms |
28032 KB |
Output is correct |
21 |
Correct |
9 ms |
29788 KB |
Output is correct |
22 |
Correct |
6 ms |
31224 KB |
Output is correct |
23 |
Correct |
6 ms |
28252 KB |
Output is correct |
24 |
Correct |
11 ms |
28252 KB |
Output is correct |
25 |
Correct |
7 ms |
28252 KB |
Output is correct |
26 |
Correct |
7 ms |
27996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
7260 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7004 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7004 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7000 KB |
Output is correct |
13 |
Correct |
1 ms |
7004 KB |
Output is correct |
14 |
Correct |
9 ms |
25948 KB |
Output is correct |
15 |
Correct |
3 ms |
22620 KB |
Output is correct |
16 |
Correct |
5 ms |
19032 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
8 ms |
29788 KB |
Output is correct |
19 |
Correct |
6 ms |
28252 KB |
Output is correct |
20 |
Correct |
6 ms |
28032 KB |
Output is correct |
21 |
Correct |
9 ms |
29788 KB |
Output is correct |
22 |
Correct |
6 ms |
31224 KB |
Output is correct |
23 |
Correct |
6 ms |
28252 KB |
Output is correct |
24 |
Correct |
11 ms |
28252 KB |
Output is correct |
25 |
Correct |
7 ms |
28252 KB |
Output is correct |
26 |
Correct |
7 ms |
27996 KB |
Output is correct |
27 |
Correct |
211 ms |
247380 KB |
Output is correct |
28 |
Correct |
14 ms |
49244 KB |
Output is correct |
29 |
Correct |
7 ms |
25948 KB |
Output is correct |
30 |
Correct |
1 ms |
4956 KB |
Output is correct |
31 |
Correct |
150 ms |
198352 KB |
Output is correct |
32 |
Correct |
157 ms |
247380 KB |
Output is correct |
33 |
Correct |
140 ms |
246996 KB |
Output is correct |
34 |
Correct |
186 ms |
229712 KB |
Output is correct |
35 |
Correct |
170 ms |
247628 KB |
Output is correct |
36 |
Correct |
143 ms |
247124 KB |
Output is correct |
37 |
Correct |
223 ms |
247380 KB |
Output is correct |
38 |
Correct |
113 ms |
197308 KB |
Output is correct |
39 |
Correct |
108 ms |
197456 KB |
Output is correct |