#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nax=3e3+3;
char m[nax][nax];
int row[nax];
int col[nax];
int q[nax];
int main(){
int h,w;
cin>>h>>w;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++){
cin>>m[i][j];
if(m[i][j]=='O')row[i]++;
if(m[i][j]=='I')col[j]++;
}
ll sol=0;
for(int i=0;i<h;i++){
int p=0;
for(int j=0;j<w;j++){
if(m[i][j]=='J'){
sol+=(ll)(row[i]-p)*(ll)(col[j]-q[j]);
}else if(m[i][j]=='O')p++;
else q[j]++;
}
}
cout<<sol<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
1 ms |
620 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
1 ms |
620 KB |
Output is correct |
13 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
1 ms |
620 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
1 ms |
620 KB |
Output is correct |
13 |
Correct |
1 ms |
620 KB |
Output is correct |
14 |
Correct |
17 ms |
1900 KB |
Output is correct |
15 |
Correct |
2 ms |
1516 KB |
Output is correct |
16 |
Correct |
9 ms |
1260 KB |
Output is correct |
17 |
Correct |
1 ms |
380 KB |
Output is correct |
18 |
Correct |
21 ms |
1900 KB |
Output is correct |
19 |
Correct |
17 ms |
1900 KB |
Output is correct |
20 |
Correct |
16 ms |
1900 KB |
Output is correct |
21 |
Correct |
20 ms |
1900 KB |
Output is correct |
22 |
Correct |
19 ms |
2048 KB |
Output is correct |
23 |
Correct |
16 ms |
1900 KB |
Output is correct |
24 |
Correct |
20 ms |
1900 KB |
Output is correct |
25 |
Correct |
17 ms |
1920 KB |
Output is correct |
26 |
Correct |
16 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
1 ms |
620 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
1 ms |
620 KB |
Output is correct |
13 |
Correct |
1 ms |
620 KB |
Output is correct |
14 |
Correct |
17 ms |
1900 KB |
Output is correct |
15 |
Correct |
2 ms |
1516 KB |
Output is correct |
16 |
Correct |
9 ms |
1260 KB |
Output is correct |
17 |
Correct |
1 ms |
380 KB |
Output is correct |
18 |
Correct |
21 ms |
1900 KB |
Output is correct |
19 |
Correct |
17 ms |
1900 KB |
Output is correct |
20 |
Correct |
16 ms |
1900 KB |
Output is correct |
21 |
Correct |
20 ms |
1900 KB |
Output is correct |
22 |
Correct |
19 ms |
2048 KB |
Output is correct |
23 |
Correct |
16 ms |
1900 KB |
Output is correct |
24 |
Correct |
20 ms |
1900 KB |
Output is correct |
25 |
Correct |
17 ms |
1920 KB |
Output is correct |
26 |
Correct |
16 ms |
1912 KB |
Output is correct |
27 |
Correct |
657 ms |
9452 KB |
Output is correct |
28 |
Correct |
6 ms |
7148 KB |
Output is correct |
29 |
Correct |
41 ms |
1772 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
485 ms |
14048 KB |
Output is correct |
32 |
Correct |
599 ms |
18236 KB |
Output is correct |
33 |
Correct |
556 ms |
17900 KB |
Output is correct |
34 |
Correct |
568 ms |
15980 KB |
Output is correct |
35 |
Correct |
610 ms |
18104 KB |
Output is correct |
36 |
Correct |
575 ms |
18072 KB |
Output is correct |
37 |
Correct |
694 ms |
18028 KB |
Output is correct |
38 |
Correct |
399 ms |
13772 KB |
Output is correct |
39 |
Correct |
390 ms |
13804 KB |
Output is correct |