#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int mat[3005][3005];
int ingots[3005];
int orbs[3005];
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
int n, m;
cin >> n >> m;
for(int i=1; i<=n; i++){
string s;
cin >> s;
for(int j=1; j<=m; j++){
if(s[j-1] == 'J') mat[i][j] = 1;
else if(s[j-1] == 'O') mat[i][j] = 2;
else mat[i][j] = 3;
}
}
ll res = 0;
for(int i=n; i>=1; i--){
for(int j=m; j>=1; j--){
if(mat[i][j] == 2) orbs[i]++;
else if(mat[i][j] == 3) ingots[j]++;
else res += ingots[j] * orbs[i];
}
}
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
716 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
716 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
7 ms |
3276 KB |
Output is correct |
15 |
Correct |
1 ms |
1996 KB |
Output is correct |
16 |
Correct |
2 ms |
1960 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
3588 KB |
Output is correct |
19 |
Correct |
4 ms |
3404 KB |
Output is correct |
20 |
Correct |
4 ms |
3404 KB |
Output is correct |
21 |
Correct |
8 ms |
3532 KB |
Output is correct |
22 |
Correct |
3 ms |
3404 KB |
Output is correct |
23 |
Correct |
4 ms |
3424 KB |
Output is correct |
24 |
Correct |
6 ms |
3532 KB |
Output is correct |
25 |
Correct |
3 ms |
3404 KB |
Output is correct |
26 |
Correct |
4 ms |
3428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
716 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
7 ms |
3276 KB |
Output is correct |
15 |
Correct |
1 ms |
1996 KB |
Output is correct |
16 |
Correct |
2 ms |
1960 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
3588 KB |
Output is correct |
19 |
Correct |
4 ms |
3404 KB |
Output is correct |
20 |
Correct |
4 ms |
3404 KB |
Output is correct |
21 |
Correct |
8 ms |
3532 KB |
Output is correct |
22 |
Correct |
3 ms |
3404 KB |
Output is correct |
23 |
Correct |
4 ms |
3424 KB |
Output is correct |
24 |
Correct |
6 ms |
3532 KB |
Output is correct |
25 |
Correct |
3 ms |
3404 KB |
Output is correct |
26 |
Correct |
4 ms |
3428 KB |
Output is correct |
27 |
Correct |
166 ms |
43888 KB |
Output is correct |
28 |
Correct |
5 ms |
9676 KB |
Output is correct |
29 |
Correct |
5 ms |
3916 KB |
Output is correct |
30 |
Correct |
1 ms |
460 KB |
Output is correct |
31 |
Correct |
124 ms |
35860 KB |
Output is correct |
32 |
Correct |
81 ms |
44408 KB |
Output is correct |
33 |
Correct |
64 ms |
44324 KB |
Output is correct |
34 |
Correct |
152 ms |
41472 KB |
Output is correct |
35 |
Correct |
70 ms |
44368 KB |
Output is correct |
36 |
Correct |
69 ms |
44312 KB |
Output is correct |
37 |
Correct |
170 ms |
44424 KB |
Output is correct |
38 |
Correct |
62 ms |
35800 KB |
Output is correct |
39 |
Correct |
52 ms |
35720 KB |
Output is correct |