#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
using namespace std;
void solve(){
int h, w; cin >> h >> w;
char g[h][w];
for( int i = 0; i < h; i++ ){ for( int j = 0; j < w; j++ ){ cin >> g[i][j]; } }
int pci[h][w]; memset( pci, 0, sizeof pci );
for( int i = h-2; i >= 0; i-- ){
for( int j = 0; j < w; j++ ){
pci[i][j] = pci[i+1][j] + ( g[i+1][j] == 'I' );
}
}
int pco[h][w]; memset( pco, 0, sizeof pco );
for( int j = w-2; j >= 0; j-- ){
for( int i = 0; i < h; i++ ){
pco[i][j] = pco[i][j+1] + ( g[i][j+1] == 'O' );
}
}
ll total = 0;
for( int i = 0; i < h; i++ ){
for( int j = 0; j < w; j++ ){
if( g[i][j] == 'J' ){ total += pci[i][j]*pco[i][j]; }
}
}
cout << total << endl;
return;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1;
//cin >> t;
while (t--) { solve(); }
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1484 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
2720 KB |
Output is correct |
19 |
Correct |
5 ms |
2568 KB |
Output is correct |
20 |
Correct |
5 ms |
2644 KB |
Output is correct |
21 |
Correct |
6 ms |
2644 KB |
Output is correct |
22 |
Correct |
5 ms |
2644 KB |
Output is correct |
23 |
Correct |
6 ms |
2636 KB |
Output is correct |
24 |
Correct |
6 ms |
2644 KB |
Output is correct |
25 |
Correct |
5 ms |
2644 KB |
Output is correct |
26 |
Correct |
5 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
2132 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1484 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
2720 KB |
Output is correct |
19 |
Correct |
5 ms |
2568 KB |
Output is correct |
20 |
Correct |
5 ms |
2644 KB |
Output is correct |
21 |
Correct |
6 ms |
2644 KB |
Output is correct |
22 |
Correct |
5 ms |
2644 KB |
Output is correct |
23 |
Correct |
6 ms |
2636 KB |
Output is correct |
24 |
Correct |
6 ms |
2644 KB |
Output is correct |
25 |
Correct |
5 ms |
2644 KB |
Output is correct |
26 |
Correct |
5 ms |
2636 KB |
Output is correct |
27 |
Correct |
275 ms |
83404 KB |
Output is correct |
28 |
Correct |
1 ms |
476 KB |
Output is correct |
29 |
Correct |
13 ms |
6560 KB |
Output is correct |
30 |
Correct |
1 ms |
456 KB |
Output is correct |
31 |
Correct |
192 ms |
61436 KB |
Output is correct |
32 |
Correct |
276 ms |
87760 KB |
Output is correct |
33 |
Correct |
278 ms |
88156 KB |
Output is correct |
34 |
Correct |
226 ms |
71220 KB |
Output is correct |
35 |
Correct |
266 ms |
87752 KB |
Output is correct |
36 |
Correct |
263 ms |
88028 KB |
Output is correct |
37 |
Correct |
303 ms |
88456 KB |
Output is correct |
38 |
Correct |
187 ms |
61004 KB |
Output is correct |
39 |
Correct |
180 ms |
61120 KB |
Output is correct |