#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll os[3003][3003], is[3003][3003];
int main()
{
int H, W;
cin>>H>>W;
string rows[3003];
for(int i=0; i<H; i++)cin>>rows[i];
for(int i=0; i<H; i++)
{
int cnt=0;
for(int j=W-1; j>=0; j--)
{
os[i][j]=cnt;
if(rows[i][j]=='O')cnt++;
}
}
for(int i=0; i<W; i++)
{
int cnt=0;
for(int j=H-1; j>=0; j--)
{
is[j][i]=cnt;
if(rows[j][i]=='I')cnt++;
}
}
ll rezz=0;
for(int i=0; i<H; i++)
{
for(int j=0; j<W; j++)
{
if(rows[i][j]=='J')rezz+=os[i][j]*is[i][j];
//cout<<os[i][j]<<" ";
}
//cout<<endl;
}
cout<<rezz;
return 0;
}
# |
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 |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1196 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 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 |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1196 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
10 ms |
7636 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
7 ms |
4692 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
12 ms |
8800 KB |
Output is correct |
19 |
Correct |
10 ms |
8404 KB |
Output is correct |
20 |
Correct |
9 ms |
8532 KB |
Output is correct |
21 |
Correct |
13 ms |
8976 KB |
Output is correct |
22 |
Correct |
12 ms |
8580 KB |
Output is correct |
23 |
Correct |
11 ms |
8844 KB |
Output is correct |
24 |
Correct |
14 ms |
9048 KB |
Output is correct |
25 |
Correct |
13 ms |
8604 KB |
Output is correct |
26 |
Correct |
9 ms |
8788 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 |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1196 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
10 ms |
7636 KB |
Output is correct |
15 |
Correct |
3 ms |
3796 KB |
Output is correct |
16 |
Correct |
7 ms |
4692 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
12 ms |
8800 KB |
Output is correct |
19 |
Correct |
10 ms |
8404 KB |
Output is correct |
20 |
Correct |
9 ms |
8532 KB |
Output is correct |
21 |
Correct |
13 ms |
8976 KB |
Output is correct |
22 |
Correct |
12 ms |
8580 KB |
Output is correct |
23 |
Correct |
11 ms |
8844 KB |
Output is correct |
24 |
Correct |
14 ms |
9048 KB |
Output is correct |
25 |
Correct |
13 ms |
8604 KB |
Output is correct |
26 |
Correct |
9 ms |
8788 KB |
Output is correct |
27 |
Correct |
444 ms |
161020 KB |
Output is correct |
28 |
Correct |
9 ms |
19540 KB |
Output is correct |
29 |
Correct |
23 ms |
14068 KB |
Output is correct |
30 |
Correct |
2 ms |
792 KB |
Output is correct |
31 |
Correct |
310 ms |
133392 KB |
Output is correct |
32 |
Correct |
439 ms |
161400 KB |
Output is correct |
33 |
Correct |
404 ms |
160912 KB |
Output is correct |
34 |
Correct |
360 ms |
154740 KB |
Output is correct |
35 |
Correct |
409 ms |
161432 KB |
Output is correct |
36 |
Correct |
398 ms |
160928 KB |
Output is correct |
37 |
Correct |
435 ms |
161532 KB |
Output is correct |
38 |
Correct |
283 ms |
132912 KB |
Output is correct |
39 |
Correct |
296 ms |
132868 KB |
Output is correct |