#include <iostream>
using namespace std;
int h, w;
long long cntfin;
int ocnts[3001][3001], icnts[3001][3001];
char s[3001][3001];
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>h>>w;
for(int i=1; i<=h; i++)
{
for(int j=1; j<=w; j++)
{
cin>>s[i][j];
ocnts[i][j]=ocnts[i][j-1]+(s[i][j]=='O');
icnts[i][j]=icnts[i-1][j]+(s[i][j]=='I');
}
}
for(int i=1; i<=h; i++)
{
for(int j=1; j<=w; j++)
{
if(s[i][j]=='J')
{
int ocnt, icnt;
ocnt=ocnts[i][w]-ocnts[i][j-1];
icnt=icnts[h][j]-icnts[i-1][j];
cntfin+=ocnt*icnt;
}
}
}
cout<<cntfin;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1656 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1656 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
7260 KB |
Output is correct |
15 |
Correct |
2 ms |
4956 KB |
Output is correct |
16 |
Correct |
3 ms |
4140 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
7 ms |
7772 KB |
Output is correct |
19 |
Correct |
5 ms |
7644 KB |
Output is correct |
20 |
Correct |
6 ms |
7772 KB |
Output is correct |
21 |
Correct |
6 ms |
7772 KB |
Output is correct |
22 |
Correct |
5 ms |
7696 KB |
Output is correct |
23 |
Correct |
5 ms |
7516 KB |
Output is correct |
24 |
Correct |
7 ms |
7772 KB |
Output is correct |
25 |
Correct |
5 ms |
7768 KB |
Output is correct |
26 |
Correct |
6 ms |
7772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1656 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
7260 KB |
Output is correct |
15 |
Correct |
2 ms |
4956 KB |
Output is correct |
16 |
Correct |
3 ms |
4140 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
7 ms |
7772 KB |
Output is correct |
19 |
Correct |
5 ms |
7644 KB |
Output is correct |
20 |
Correct |
6 ms |
7772 KB |
Output is correct |
21 |
Correct |
6 ms |
7772 KB |
Output is correct |
22 |
Correct |
5 ms |
7696 KB |
Output is correct |
23 |
Correct |
5 ms |
7516 KB |
Output is correct |
24 |
Correct |
7 ms |
7772 KB |
Output is correct |
25 |
Correct |
5 ms |
7768 KB |
Output is correct |
26 |
Correct |
6 ms |
7772 KB |
Output is correct |
27 |
Correct |
132 ms |
79716 KB |
Output is correct |
28 |
Correct |
12 ms |
25944 KB |
Output is correct |
29 |
Correct |
10 ms |
7768 KB |
Output is correct |
30 |
Correct |
1 ms |
600 KB |
Output is correct |
31 |
Correct |
103 ms |
72560 KB |
Output is correct |
32 |
Correct |
119 ms |
88404 KB |
Output is correct |
33 |
Correct |
118 ms |
88144 KB |
Output is correct |
34 |
Correct |
121 ms |
84164 KB |
Output is correct |
35 |
Correct |
111 ms |
88244 KB |
Output is correct |
36 |
Correct |
107 ms |
88144 KB |
Output is correct |
37 |
Correct |
134 ms |
88404 KB |
Output is correct |
38 |
Correct |
81 ms |
72532 KB |
Output is correct |
39 |
Correct |
90 ms |
72276 KB |
Output is correct |