#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define epb emplace_back
using namespace std;
int prefr[3001][3001], prefc[3001][3001];
int main(){
int n, m; cin >> n >> m;
char c[n + 1][m + 1];
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++){
prefr[i][0] = 0;
for(int j = 1; j <= m; j++) {
prefr[i][j] = prefr[i][j - 1];
if(c[i][j] == 'O') prefr[i][j]++;
}
}
for(int j = 1; j <= m; j++){
prefc[0][j] = 0;
for(int i = 1; i <= n; i++){
prefc[i][j] = prefc[i - 1][j];
if(c[i][j] == 'I') prefc[i][j]++;
}
}
ll ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(c[i][j] == 'J'){
ll x = prefr[i][m] - prefr[i][j];
ll y = prefc[n][j] - prefc[i][j];
ans += x * y;
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
2 ms |
1216 KB |
Output is correct |
9 |
Correct |
1 ms |
1080 KB |
Output is correct |
10 |
Correct |
2 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
2 ms |
1216 KB |
Output is correct |
9 |
Correct |
1 ms |
1080 KB |
Output is correct |
10 |
Correct |
2 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
15 ms |
6100 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
9 ms |
3540 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
18 ms |
6668 KB |
Output is correct |
19 |
Correct |
17 ms |
6596 KB |
Output is correct |
20 |
Correct |
18 ms |
6588 KB |
Output is correct |
21 |
Correct |
20 ms |
6704 KB |
Output is correct |
22 |
Correct |
17 ms |
6588 KB |
Output is correct |
23 |
Correct |
17 ms |
6612 KB |
Output is correct |
24 |
Correct |
19 ms |
6740 KB |
Output is correct |
25 |
Correct |
17 ms |
6528 KB |
Output is correct |
26 |
Correct |
17 ms |
6540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
2 ms |
1216 KB |
Output is correct |
9 |
Correct |
1 ms |
1080 KB |
Output is correct |
10 |
Correct |
2 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
15 ms |
6100 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
9 ms |
3540 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
18 ms |
6668 KB |
Output is correct |
19 |
Correct |
17 ms |
6596 KB |
Output is correct |
20 |
Correct |
18 ms |
6588 KB |
Output is correct |
21 |
Correct |
20 ms |
6704 KB |
Output is correct |
22 |
Correct |
17 ms |
6588 KB |
Output is correct |
23 |
Correct |
17 ms |
6612 KB |
Output is correct |
24 |
Correct |
19 ms |
6740 KB |
Output is correct |
25 |
Correct |
17 ms |
6528 KB |
Output is correct |
26 |
Correct |
17 ms |
6540 KB |
Output is correct |
27 |
Correct |
668 ms |
87312 KB |
Output is correct |
28 |
Correct |
9 ms |
19156 KB |
Output is correct |
29 |
Correct |
40 ms |
7556 KB |
Output is correct |
30 |
Correct |
2 ms |
572 KB |
Output is correct |
31 |
Correct |
486 ms |
71160 KB |
Output is correct |
32 |
Correct |
663 ms |
88252 KB |
Output is correct |
33 |
Correct |
654 ms |
88192 KB |
Output is correct |
34 |
Correct |
567 ms |
82504 KB |
Output is correct |
35 |
Correct |
665 ms |
88184 KB |
Output is correct |
36 |
Correct |
671 ms |
87996 KB |
Output is correct |
37 |
Correct |
723 ms |
88304 KB |
Output is correct |
38 |
Correct |
460 ms |
71220 KB |
Output is correct |
39 |
Correct |
443 ms |
70940 KB |
Output is correct |