#include <bits/stdc++.h>
using namespace std;
#define N 3005
#define LL long long
#define pii pair<LL,LL>
LL h, w, ans;
char c;
LL o[N][N], i[N][N];
vector<pii> j;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> h >> w;
for (int x=1; x<=h; x++)
for (int y=1; y<=w; y++)
{
cin >> c;
if (c=='J') j.push_back({x,y});
o[x][y]=o[x][y-1]+(c=='O');
i[x][y]=i[x-1][y]+(c=='I');
}
ans=0;
for (auto now:j)
{
int a=now.first, b=now.second;
ans+=(o[a][w]-o[a][b])*(i[h][b]-i[a][b]);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
7004 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
7004 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
7 ms |
18904 KB |
Output is correct |
15 |
Correct |
3 ms |
12380 KB |
Output is correct |
16 |
Correct |
4 ms |
10964 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
9 ms |
19412 KB |
Output is correct |
19 |
Correct |
7 ms |
18396 KB |
Output is correct |
20 |
Correct |
8 ms |
19412 KB |
Output is correct |
21 |
Correct |
9 ms |
19668 KB |
Output is correct |
22 |
Correct |
8 ms |
19668 KB |
Output is correct |
23 |
Correct |
8 ms |
19668 KB |
Output is correct |
24 |
Correct |
9 ms |
19920 KB |
Output is correct |
25 |
Correct |
7 ms |
18648 KB |
Output is correct |
26 |
Correct |
7 ms |
19664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
7004 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
7 ms |
18904 KB |
Output is correct |
15 |
Correct |
3 ms |
12380 KB |
Output is correct |
16 |
Correct |
4 ms |
10964 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
9 ms |
19412 KB |
Output is correct |
19 |
Correct |
7 ms |
18396 KB |
Output is correct |
20 |
Correct |
8 ms |
19412 KB |
Output is correct |
21 |
Correct |
9 ms |
19668 KB |
Output is correct |
22 |
Correct |
8 ms |
19668 KB |
Output is correct |
23 |
Correct |
8 ms |
19668 KB |
Output is correct |
24 |
Correct |
9 ms |
19920 KB |
Output is correct |
25 |
Correct |
7 ms |
18648 KB |
Output is correct |
26 |
Correct |
7 ms |
19664 KB |
Output is correct |
27 |
Correct |
246 ms |
195176 KB |
Output is correct |
28 |
Correct |
11 ms |
65760 KB |
Output is correct |
29 |
Correct |
13 ms |
18384 KB |
Output is correct |
30 |
Correct |
2 ms |
3164 KB |
Output is correct |
31 |
Correct |
133 ms |
160128 KB |
Output is correct |
32 |
Correct |
149 ms |
163840 KB |
Output is correct |
33 |
Correct |
191 ms |
198560 KB |
Output is correct |
34 |
Correct |
194 ms |
195244 KB |
Output is correct |
35 |
Correct |
246 ms |
197956 KB |
Output is correct |
36 |
Correct |
165 ms |
197720 KB |
Output is correct |
37 |
Correct |
221 ms |
207664 KB |
Output is correct |
38 |
Correct |
106 ms |
137812 KB |
Output is correct |
39 |
Correct |
104 ms |
157412 KB |
Output is correct |