#include <bits/stdc++.h>
#define ll long long
#define pll pair<int, int>
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MX=3005;
int h, w, prefr[MX][MX], prefc[MX][MX];
ll ans;
char g[MX][MX];
int main(){
cin >> h >> w;
vector<pll> start;
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
cin >> g[i][j];
if(g[i][j]=='J') start.pb({i, j});
prefr[i][j]=prefr[i][j-1];
prefc[j][i]=prefc[j][i-1];
if(g[i][j]=='O') prefr[i][j]++;
if(g[i][j]=='I') prefc[j][i]++;
}
}
for(auto i : start){
int r=i.fi, c=i.se;
// cout << r << " " << c << endl;
int oo=(prefr[r][w]-prefr[r][c]);
int ii=(prefc[c][h]-prefc[c][r]);
// cout << "nilai " << ii << " " << oo << endl;
ans+=ii*oo;
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 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 |
1364 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 |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 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 |
1364 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 |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
13 ms |
7472 KB |
Output is correct |
15 |
Correct |
3 ms |
3284 KB |
Output is correct |
16 |
Correct |
8 ms |
5580 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
15 ms |
8520 KB |
Output is correct |
19 |
Correct |
13 ms |
7876 KB |
Output is correct |
20 |
Correct |
13 ms |
8392 KB |
Output is correct |
21 |
Correct |
16 ms |
8560 KB |
Output is correct |
22 |
Correct |
14 ms |
8364 KB |
Output is correct |
23 |
Correct |
15 ms |
8404 KB |
Output is correct |
24 |
Correct |
17 ms |
8676 KB |
Output is correct |
25 |
Correct |
13 ms |
7920 KB |
Output is correct |
26 |
Correct |
14 ms |
8424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 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 |
1364 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 |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
13 ms |
7472 KB |
Output is correct |
15 |
Correct |
3 ms |
3284 KB |
Output is correct |
16 |
Correct |
8 ms |
5580 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
15 ms |
8520 KB |
Output is correct |
19 |
Correct |
13 ms |
7876 KB |
Output is correct |
20 |
Correct |
13 ms |
8392 KB |
Output is correct |
21 |
Correct |
16 ms |
8560 KB |
Output is correct |
22 |
Correct |
14 ms |
8364 KB |
Output is correct |
23 |
Correct |
15 ms |
8404 KB |
Output is correct |
24 |
Correct |
17 ms |
8676 KB |
Output is correct |
25 |
Correct |
13 ms |
7920 KB |
Output is correct |
26 |
Correct |
14 ms |
8424 KB |
Output is correct |
27 |
Correct |
514 ms |
99796 KB |
Output is correct |
28 |
Correct |
12 ms |
16852 KB |
Output is correct |
29 |
Correct |
65 ms |
18568 KB |
Output is correct |
30 |
Correct |
7 ms |
9808 KB |
Output is correct |
31 |
Correct |
395 ms |
82648 KB |
Output is correct |
32 |
Correct |
512 ms |
86208 KB |
Output is correct |
33 |
Correct |
550 ms |
103040 KB |
Output is correct |
34 |
Correct |
465 ms |
99988 KB |
Output is correct |
35 |
Correct |
583 ms |
102280 KB |
Output is correct |
36 |
Correct |
542 ms |
103088 KB |
Output is correct |
37 |
Correct |
617 ms |
108016 KB |
Output is correct |
38 |
Correct |
326 ms |
71412 KB |
Output is correct |
39 |
Correct |
366 ms |
82588 KB |
Output is correct |