#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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
760 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
760 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
14 |
Correct |
7 ms |
3320 KB |
Output is correct |
15 |
Correct |
4 ms |
2040 KB |
Output is correct |
16 |
Correct |
4 ms |
2040 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
8 ms |
3576 KB |
Output is correct |
19 |
Correct |
6 ms |
3448 KB |
Output is correct |
20 |
Correct |
6 ms |
3576 KB |
Output is correct |
21 |
Correct |
8 ms |
3576 KB |
Output is correct |
22 |
Correct |
6 ms |
3576 KB |
Output is correct |
23 |
Correct |
5 ms |
3448 KB |
Output is correct |
24 |
Correct |
8 ms |
3576 KB |
Output is correct |
25 |
Correct |
6 ms |
3576 KB |
Output is correct |
26 |
Correct |
6 ms |
3576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
2 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
2 ms |
760 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
760 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
14 |
Correct |
7 ms |
3320 KB |
Output is correct |
15 |
Correct |
4 ms |
2040 KB |
Output is correct |
16 |
Correct |
4 ms |
2040 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
8 ms |
3576 KB |
Output is correct |
19 |
Correct |
6 ms |
3448 KB |
Output is correct |
20 |
Correct |
6 ms |
3576 KB |
Output is correct |
21 |
Correct |
8 ms |
3576 KB |
Output is correct |
22 |
Correct |
6 ms |
3576 KB |
Output is correct |
23 |
Correct |
5 ms |
3448 KB |
Output is correct |
24 |
Correct |
8 ms |
3576 KB |
Output is correct |
25 |
Correct |
6 ms |
3576 KB |
Output is correct |
26 |
Correct |
6 ms |
3576 KB |
Output is correct |
27 |
Correct |
146 ms |
44004 KB |
Output is correct |
28 |
Correct |
10 ms |
9848 KB |
Output is correct |
29 |
Correct |
9 ms |
4088 KB |
Output is correct |
30 |
Correct |
2 ms |
504 KB |
Output is correct |
31 |
Correct |
112 ms |
36052 KB |
Output is correct |
32 |
Correct |
76 ms |
44408 KB |
Output is correct |
33 |
Correct |
68 ms |
44408 KB |
Output is correct |
34 |
Correct |
129 ms |
41740 KB |
Output is correct |
35 |
Correct |
84 ms |
44368 KB |
Output is correct |
36 |
Correct |
67 ms |
44408 KB |
Output is correct |
37 |
Correct |
155 ms |
44544 KB |
Output is correct |
38 |
Correct |
56 ms |
35832 KB |
Output is correct |
39 |
Correct |
51 ms |
35704 KB |
Output is correct |