#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxx = 3010;
int shemsh[maxx][maxx] , goi[maxx][maxx] , javaher[maxx][maxx];
char s[maxx][maxx];
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n , m;
cin>>n>>m;
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= m ; j++){
cin>>s[i][j];
}
}
for(int j = 1 ; j <= m ; j++){
for(int i = n ; i >= 1 ; i--){
javaher[i][j] = javaher[i+1][j];
if(s[i][j] == 'I')javaher[i][j]++;
}
}
for(int i = 1 ; i <= n ; i++){
for(int j = m ;j >= 1 ; j--){
shemsh[i][j] = shemsh[i][j+1];
if(s[i][j] == 'O')shemsh[i][j]++;
}
}
int ans = 0;
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= m ; j++){
if(s[i][j] == 'J'){
ans+=shemsh[i][j] * javaher[i][j];
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
5212 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5208 KB |
Output is correct |
11 |
Correct |
2 ms |
5212 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
5212 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5208 KB |
Output is correct |
11 |
Correct |
2 ms |
5212 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
17036 KB |
Output is correct |
15 |
Correct |
3 ms |
14684 KB |
Output is correct |
16 |
Correct |
6 ms |
10844 KB |
Output is correct |
17 |
Correct |
1 ms |
768 KB |
Output is correct |
18 |
Correct |
13 ms |
17668 KB |
Output is correct |
19 |
Correct |
11 ms |
17496 KB |
Output is correct |
20 |
Correct |
11 ms |
17432 KB |
Output is correct |
21 |
Correct |
14 ms |
17520 KB |
Output is correct |
22 |
Correct |
11 ms |
17500 KB |
Output is correct |
23 |
Correct |
8 ms |
17244 KB |
Output is correct |
24 |
Correct |
12 ms |
17500 KB |
Output is correct |
25 |
Correct |
12 ms |
17384 KB |
Output is correct |
26 |
Correct |
9 ms |
17296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
5212 KB |
Output is correct |
6 |
Correct |
2 ms |
5212 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
2 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5208 KB |
Output is correct |
11 |
Correct |
2 ms |
5212 KB |
Output is correct |
12 |
Correct |
2 ms |
5212 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
17036 KB |
Output is correct |
15 |
Correct |
3 ms |
14684 KB |
Output is correct |
16 |
Correct |
6 ms |
10844 KB |
Output is correct |
17 |
Correct |
1 ms |
768 KB |
Output is correct |
18 |
Correct |
13 ms |
17668 KB |
Output is correct |
19 |
Correct |
11 ms |
17496 KB |
Output is correct |
20 |
Correct |
11 ms |
17432 KB |
Output is correct |
21 |
Correct |
14 ms |
17520 KB |
Output is correct |
22 |
Correct |
11 ms |
17500 KB |
Output is correct |
23 |
Correct |
8 ms |
17244 KB |
Output is correct |
24 |
Correct |
12 ms |
17500 KB |
Output is correct |
25 |
Correct |
12 ms |
17384 KB |
Output is correct |
26 |
Correct |
9 ms |
17296 KB |
Output is correct |
27 |
Correct |
270 ms |
150672 KB |
Output is correct |
28 |
Correct |
15 ms |
71952 KB |
Output is correct |
29 |
Correct |
23 ms |
15232 KB |
Output is correct |
30 |
Correct |
2 ms |
860 KB |
Output is correct |
31 |
Correct |
209 ms |
127052 KB |
Output is correct |
32 |
Correct |
216 ms |
150532 KB |
Output is correct |
33 |
Correct |
256 ms |
150176 KB |
Output is correct |
34 |
Correct |
247 ms |
145988 KB |
Output is correct |
35 |
Correct |
223 ms |
150456 KB |
Output is correct |
36 |
Correct |
219 ms |
150396 KB |
Output is correct |
37 |
Correct |
271 ms |
150648 KB |
Output is correct |
38 |
Correct |
168 ms |
126588 KB |
Output is correct |
39 |
Correct |
167 ms |
126444 KB |
Output is correct |