#include <bits/stdc++.h>
using namespace std;
#define ll long long
char wej[3003][3003];
ll row[3003][3003];
ll col[3003][3003];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,m;
cin >> n >> m;
for (ll i = 1; i<=n; i++){
for (ll j = 1; j<=m; j++){
cin >> wej[i][j];
row[i][j]=row[i][j-1];
col[i][j]=col[i-1][j];
if (wej[i][j]=='O')row[i][j]++;
if (wej[i][j]=='I')col[i][j]++;
}
}
ll ans=0;
for (ll i = 1; i<=n; i++){
for (ll j = 1; j<=m; j++){
if (wej[i][j]=='J')ans+=(col[n][j]-col[i-1][j])*(row[i][m]-row[i][j-1]);
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
2 ms |
7128 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
7004 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
2 ms |
7004 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
2 ms |
7128 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
7004 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
2 ms |
7004 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
9 ms |
21868 KB |
Output is correct |
15 |
Correct |
3 ms |
16476 KB |
Output is correct |
16 |
Correct |
4 ms |
14172 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
9 ms |
22488 KB |
Output is correct |
19 |
Correct |
7 ms |
22364 KB |
Output is correct |
20 |
Correct |
6 ms |
22208 KB |
Output is correct |
21 |
Correct |
9 ms |
22360 KB |
Output is correct |
22 |
Correct |
7 ms |
22212 KB |
Output is correct |
23 |
Correct |
7 ms |
22364 KB |
Output is correct |
24 |
Correct |
9 ms |
22364 KB |
Output is correct |
25 |
Correct |
7 ms |
22364 KB |
Output is correct |
26 |
Correct |
6 ms |
22404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
7004 KB |
Output is correct |
6 |
Correct |
2 ms |
7128 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
7004 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
7004 KB |
Output is correct |
12 |
Correct |
2 ms |
7004 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
9 ms |
21868 KB |
Output is correct |
15 |
Correct |
3 ms |
16476 KB |
Output is correct |
16 |
Correct |
4 ms |
14172 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
9 ms |
22488 KB |
Output is correct |
19 |
Correct |
7 ms |
22364 KB |
Output is correct |
20 |
Correct |
6 ms |
22208 KB |
Output is correct |
21 |
Correct |
9 ms |
22360 KB |
Output is correct |
22 |
Correct |
7 ms |
22212 KB |
Output is correct |
23 |
Correct |
7 ms |
22364 KB |
Output is correct |
24 |
Correct |
9 ms |
22364 KB |
Output is correct |
25 |
Correct |
7 ms |
22364 KB |
Output is correct |
26 |
Correct |
6 ms |
22404 KB |
Output is correct |
27 |
Correct |
241 ms |
158432 KB |
Output is correct |
28 |
Correct |
13 ms |
75612 KB |
Output is correct |
29 |
Correct |
12 ms |
19036 KB |
Output is correct |
30 |
Correct |
2 ms |
4828 KB |
Output is correct |
31 |
Correct |
151 ms |
135252 KB |
Output is correct |
32 |
Correct |
137 ms |
159048 KB |
Output is correct |
33 |
Correct |
113 ms |
158804 KB |
Output is correct |
34 |
Correct |
179 ms |
156780 KB |
Output is correct |
35 |
Correct |
149 ms |
159056 KB |
Output is correct |
36 |
Correct |
111 ms |
158784 KB |
Output is correct |
37 |
Correct |
212 ms |
159260 KB |
Output is correct |
38 |
Correct |
97 ms |
135080 KB |
Output is correct |
39 |
Correct |
83 ms |
135252 KB |
Output is correct |