#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
const int mxN = (int)1e3+10;
string a[mxN];
int n, m, ans, r[mxN][mxN], c[mxN][mxN];
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++){
cin >> a[i];
for(int j = m-1; j>=0; j--)
r[i][j]=r[i][j+1]+(a[i][j]=='O');
}
for(int j = 0; j < m; j++)
for(int i = n-1; i>=0; i--)
c[i][j]=c[i+1][j]+(a[i][j]=='I');
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
if(a[i][j]=='J') ans+=r[i][j+1]*c[i+1][j];
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
356 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1288 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
356 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1288 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1136 KB |
Output is correct |
14 |
Correct |
5 ms |
7636 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
4708 KB |
Output is correct |
17 |
Correct |
1 ms |
396 KB |
Output is correct |
18 |
Correct |
7 ms |
8688 KB |
Output is correct |
19 |
Correct |
6 ms |
8532 KB |
Output is correct |
20 |
Correct |
6 ms |
8524 KB |
Output is correct |
21 |
Correct |
6 ms |
8660 KB |
Output is correct |
22 |
Correct |
6 ms |
8532 KB |
Output is correct |
23 |
Correct |
6 ms |
8532 KB |
Output is correct |
24 |
Correct |
7 ms |
8696 KB |
Output is correct |
25 |
Correct |
7 ms |
8560 KB |
Output is correct |
26 |
Correct |
6 ms |
8488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
356 KB |
Output is correct |
4 |
Correct |
1 ms |
340 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 |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1288 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1136 KB |
Output is correct |
14 |
Correct |
5 ms |
7636 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
4708 KB |
Output is correct |
17 |
Correct |
1 ms |
396 KB |
Output is correct |
18 |
Correct |
7 ms |
8688 KB |
Output is correct |
19 |
Correct |
6 ms |
8532 KB |
Output is correct |
20 |
Correct |
6 ms |
8524 KB |
Output is correct |
21 |
Correct |
6 ms |
8660 KB |
Output is correct |
22 |
Correct |
6 ms |
8532 KB |
Output is correct |
23 |
Correct |
6 ms |
8532 KB |
Output is correct |
24 |
Correct |
7 ms |
8696 KB |
Output is correct |
25 |
Correct |
7 ms |
8560 KB |
Output is correct |
26 |
Correct |
6 ms |
8488 KB |
Output is correct |
27 |
Runtime error |
27 ms |
25992 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |