#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 , ans ;
int 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 |
348 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 |
3 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
2 ms |
3376 KB |
Output is correct |
8 |
Correct |
2 ms |
3524 KB |
Output is correct |
9 |
Correct |
2 ms |
3420 KB |
Output is correct |
10 |
Correct |
2 ms |
3516 KB |
Output is correct |
11 |
Correct |
3 ms |
3420 KB |
Output is correct |
12 |
Correct |
2 ms |
3420 KB |
Output is correct |
13 |
Correct |
3 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 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 |
3 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
2 ms |
3376 KB |
Output is correct |
8 |
Correct |
2 ms |
3524 KB |
Output is correct |
9 |
Correct |
2 ms |
3420 KB |
Output is correct |
10 |
Correct |
2 ms |
3516 KB |
Output is correct |
11 |
Correct |
3 ms |
3420 KB |
Output is correct |
12 |
Correct |
2 ms |
3420 KB |
Output is correct |
13 |
Correct |
3 ms |
3420 KB |
Output is correct |
14 |
Correct |
11 ms |
11688 KB |
Output is correct |
15 |
Correct |
4 ms |
8796 KB |
Output is correct |
16 |
Correct |
8 ms |
7144 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
17 ms |
12124 KB |
Output is correct |
19 |
Correct |
13 ms |
11972 KB |
Output is correct |
20 |
Incorrect |
14 ms |
11868 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 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 |
3 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
2 ms |
3376 KB |
Output is correct |
8 |
Correct |
2 ms |
3524 KB |
Output is correct |
9 |
Correct |
2 ms |
3420 KB |
Output is correct |
10 |
Correct |
2 ms |
3516 KB |
Output is correct |
11 |
Correct |
3 ms |
3420 KB |
Output is correct |
12 |
Correct |
2 ms |
3420 KB |
Output is correct |
13 |
Correct |
3 ms |
3420 KB |
Output is correct |
14 |
Correct |
11 ms |
11688 KB |
Output is correct |
15 |
Correct |
4 ms |
8796 KB |
Output is correct |
16 |
Correct |
8 ms |
7144 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
17 ms |
12124 KB |
Output is correct |
19 |
Correct |
13 ms |
11972 KB |
Output is correct |
20 |
Incorrect |
14 ms |
11868 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |