#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=3003;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const ll inf=1e18;
const int K=600;
int rig[mxN][mxN], down[mxN][mxN];
string s[mxN];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int m, n; cin >> m >> n;
for(int j=0; j<m; j++) cin >> s[j];
ll ans=0;
for(int j=m-1; j>=0; j--)
{
for(int i=n-1; i>=0; i--)
{
rig[j][i]=rig[j][i+1]+(s[j][i]=='O');
down[j][i]=down[j+1][i]+(s[j][i]=='I');
if(s[j][i]=='J') ans+=rig[j][i]*down[j][i];
}
}
cout << ans << "\n";
}
/*
7 3
4 1 3 4 0 2 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
428 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1200 KB |
Output is correct |
8 |
Correct |
1 ms |
1200 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
2 ms |
1324 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1196 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
428 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1200 KB |
Output is correct |
8 |
Correct |
1 ms |
1200 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
2 ms |
1324 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1196 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
5 ms |
6228 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
3668 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
6 ms |
6812 KB |
Output is correct |
19 |
Correct |
5 ms |
6740 KB |
Output is correct |
20 |
Correct |
5 ms |
6740 KB |
Output is correct |
21 |
Correct |
6 ms |
6820 KB |
Output is correct |
22 |
Correct |
6 ms |
6740 KB |
Output is correct |
23 |
Correct |
5 ms |
6704 KB |
Output is correct |
24 |
Correct |
5 ms |
6832 KB |
Output is correct |
25 |
Correct |
5 ms |
6740 KB |
Output is correct |
26 |
Correct |
4 ms |
6740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
428 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1200 KB |
Output is correct |
8 |
Correct |
1 ms |
1200 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
2 ms |
1324 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1196 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
5 ms |
6228 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
3668 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
6 ms |
6812 KB |
Output is correct |
19 |
Correct |
5 ms |
6740 KB |
Output is correct |
20 |
Correct |
5 ms |
6740 KB |
Output is correct |
21 |
Correct |
6 ms |
6820 KB |
Output is correct |
22 |
Correct |
6 ms |
6740 KB |
Output is correct |
23 |
Correct |
5 ms |
6704 KB |
Output is correct |
24 |
Correct |
5 ms |
6832 KB |
Output is correct |
25 |
Correct |
5 ms |
6740 KB |
Output is correct |
26 |
Correct |
4 ms |
6740 KB |
Output is correct |
27 |
Correct |
97 ms |
88240 KB |
Output is correct |
28 |
Correct |
12 ms |
19284 KB |
Output is correct |
29 |
Correct |
6 ms |
7844 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
64 ms |
71856 KB |
Output is correct |
32 |
Correct |
71 ms |
89184 KB |
Output is correct |
33 |
Correct |
79 ms |
89132 KB |
Output is correct |
34 |
Correct |
77 ms |
83280 KB |
Output is correct |
35 |
Correct |
74 ms |
89176 KB |
Output is correct |
36 |
Correct |
68 ms |
89092 KB |
Output is correct |
37 |
Correct |
91 ms |
89360 KB |
Output is correct |
38 |
Correct |
51 ms |
71776 KB |
Output is correct |
39 |
Correct |
56 ms |
71624 KB |
Output is correct |