#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
char mat[3001][3001];
ll oDesno[3001][3001];
ll iDole[3001][3001];
ll getO (ll i, ll j) {
if (j != 0) return oDesno[i][j-1];
else return 0;
}
ll getI (ll i, ll j) {
if (i != 0) return iDole[i-1][j];
else return 0;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n,m;
cin>>n>>m;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
cin>>mat[i][j];
oDesno[i][j] = (mat[i][j] == 'O') + getO(i,j);
iDole[i][j] = (mat[i][j] == 'I') + getI(i,j);
}
}
ll res = 0;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
if (mat[i][j] != 'J') continue;
res += (oDesno[i][m-1]-oDesno[i][j]) * (iDole[n-1][j]-iDole[i][j]);
}
}
cout<<res<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
8964 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
9 ms |
9940 KB |
Output is correct |
19 |
Correct |
9 ms |
9812 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
9 ms |
9992 KB |
Output is correct |
22 |
Correct |
10 ms |
9812 KB |
Output is correct |
23 |
Correct |
8 ms |
9684 KB |
Output is correct |
24 |
Correct |
9 ms |
9980 KB |
Output is correct |
25 |
Correct |
7 ms |
9800 KB |
Output is correct |
26 |
Correct |
7 ms |
9708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
8964 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5332 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
9 ms |
9940 KB |
Output is correct |
19 |
Correct |
9 ms |
9812 KB |
Output is correct |
20 |
Correct |
8 ms |
9684 KB |
Output is correct |
21 |
Correct |
9 ms |
9992 KB |
Output is correct |
22 |
Correct |
10 ms |
9812 KB |
Output is correct |
23 |
Correct |
8 ms |
9684 KB |
Output is correct |
24 |
Correct |
9 ms |
9980 KB |
Output is correct |
25 |
Correct |
7 ms |
9800 KB |
Output is correct |
26 |
Correct |
7 ms |
9708 KB |
Output is correct |
27 |
Correct |
194 ms |
158380 KB |
Output is correct |
28 |
Correct |
14 ms |
26204 KB |
Output is correct |
29 |
Correct |
15 ms |
13784 KB |
Output is correct |
30 |
Correct |
1 ms |
716 KB |
Output is correct |
31 |
Correct |
150 ms |
131188 KB |
Output is correct |
32 |
Correct |
179 ms |
158740 KB |
Output is correct |
33 |
Correct |
183 ms |
158352 KB |
Output is correct |
34 |
Correct |
172 ms |
152152 KB |
Output is correct |
35 |
Correct |
183 ms |
158804 KB |
Output is correct |
36 |
Correct |
181 ms |
158268 KB |
Output is correct |
37 |
Correct |
213 ms |
158796 KB |
Output is correct |
38 |
Correct |
142 ms |
130752 KB |
Output is correct |
39 |
Correct |
147 ms |
130632 KB |
Output is correct |