#include <bits/stdc++.h>
using namespace std;
#define pt "--> "
#define Fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll ;
const int N = 3e3 + 7 , lg = 27 , len = 340 , Sq = 350 , oo = 2e9 , mod = 998244353 ;
int dx[9] = {0 , -1 , 0 , 1 , 0 , 1 , 1 , -1 , -1} , dy[9] = {0 , 0 , -1 , 0 , 1 , 1 , -1 , 1 , -1} ;
int n , m ;
ll ans ;
ll dp[N][N] , pd[N][N] ;
char c[N][N] ;
void solve() {
cin >> n >> m ;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
cin >> c[i][j] ;
for(int i = 1 ; i <= n ; i++)
for(int j = m ; j ; j--)
dp[i][j] = dp[i][j+1] + (c[i][j] == 'O') ;
for(int j = 1 ; j <= m ; j++)
for(int i = n ; i ; i--)
pd[i][j] = pd[i+1][j] + (c[i][j] == 'I') ;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
if(c[i][j] == 'J')
ans += dp[i][j] * pd[i][j] ;
cout << ans << endl ;
}
int main(){
// Fast() ;
int T = 1 ;
while(T--)
solve() ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
5368 KB |
Output is correct |
6 |
Correct |
1 ms |
5208 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
3 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5208 KB |
Output is correct |
12 |
Correct |
2 ms |
5208 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
5368 KB |
Output is correct |
6 |
Correct |
1 ms |
5208 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
3 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5208 KB |
Output is correct |
12 |
Correct |
2 ms |
5208 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
12 ms |
16984 KB |
Output is correct |
15 |
Correct |
4 ms |
14684 KB |
Output is correct |
16 |
Correct |
11 ms |
10844 KB |
Output is correct |
17 |
Correct |
1 ms |
856 KB |
Output is correct |
18 |
Correct |
16 ms |
17516 KB |
Output is correct |
19 |
Correct |
15 ms |
17268 KB |
Output is correct |
20 |
Correct |
15 ms |
17240 KB |
Output is correct |
21 |
Correct |
15 ms |
17772 KB |
Output is correct |
22 |
Correct |
14 ms |
17496 KB |
Output is correct |
23 |
Correct |
21 ms |
17496 KB |
Output is correct |
24 |
Correct |
18 ms |
17756 KB |
Output is correct |
25 |
Correct |
19 ms |
17500 KB |
Output is correct |
26 |
Correct |
17 ms |
17648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
5368 KB |
Output is correct |
6 |
Correct |
1 ms |
5208 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
3 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
2 ms |
5212 KB |
Output is correct |
11 |
Correct |
2 ms |
5208 KB |
Output is correct |
12 |
Correct |
2 ms |
5208 KB |
Output is correct |
13 |
Correct |
2 ms |
5212 KB |
Output is correct |
14 |
Correct |
12 ms |
16984 KB |
Output is correct |
15 |
Correct |
4 ms |
14684 KB |
Output is correct |
16 |
Correct |
11 ms |
10844 KB |
Output is correct |
17 |
Correct |
1 ms |
856 KB |
Output is correct |
18 |
Correct |
16 ms |
17516 KB |
Output is correct |
19 |
Correct |
15 ms |
17268 KB |
Output is correct |
20 |
Correct |
15 ms |
17240 KB |
Output is correct |
21 |
Correct |
15 ms |
17772 KB |
Output is correct |
22 |
Correct |
14 ms |
17496 KB |
Output is correct |
23 |
Correct |
21 ms |
17496 KB |
Output is correct |
24 |
Correct |
18 ms |
17756 KB |
Output is correct |
25 |
Correct |
19 ms |
17500 KB |
Output is correct |
26 |
Correct |
17 ms |
17648 KB |
Output is correct |
27 |
Correct |
438 ms |
158820 KB |
Output is correct |
28 |
Correct |
17 ms |
72028 KB |
Output is correct |
29 |
Correct |
32 ms |
15800 KB |
Output is correct |
30 |
Correct |
2 ms |
860 KB |
Output is correct |
31 |
Correct |
342 ms |
132944 KB |
Output is correct |
32 |
Correct |
461 ms |
159092 KB |
Output is correct |
33 |
Correct |
491 ms |
158824 KB |
Output is correct |
34 |
Correct |
403 ms |
152796 KB |
Output is correct |
35 |
Correct |
445 ms |
159200 KB |
Output is correct |
36 |
Correct |
490 ms |
158612 KB |
Output is correct |
37 |
Correct |
466 ms |
159304 KB |
Output is correct |
38 |
Correct |
297 ms |
132704 KB |
Output is correct |
39 |
Correct |
308 ms |
132572 KB |
Output is correct |