#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el cout<<endl;
#define fr(n,m) for(int i=n;i<m;i++)
#define frj(n,m) for(int j=n;j<m;j++)
#define frl(n,m) for(int l=n;l<m;l++)
#define frd(n,m) for(int d=n;d<m;d++)
#define mii map<int,int>
#define mci map<char,int>
#define vi vector<int>
#define vc vector<char>
#define mivi map<int,vi>
const int mod = 1e9 + 7;
// const int mod=998
int i = 0, j = 0, k = 0, l = 0, h = 0, w = 0, a = 0, b = 0, c = 0, d = 0;
int num = 0, ans = 0, sum = 0;
const int N = 1e3 + 5;
void solve() {
cin >> h >> w;
vector<string>v(h);
mii mi;
mii mo;
fr(0, h) {
cin >> v[i];
frj(0, w) {
if (v[i][j] == 'I') {
mi[j]++;
}
else if (v[i][j] == 'O') {
mo[i]++;
}
}
}
fr(0, h) {
frj(0, w) {
if (v[i][j] == 'J') {
ans += mi[j] * mo[i];
}
else if (v[i][j] == 'I') {
mi[j]--;
}
else {
mo[i]--;
}
}
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
cout << fixed << setprecision(12); solve();
el;
} return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
340 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
340 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 |
14 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
18 ms |
660 KB |
Output is correct |
19 |
Correct |
8 ms |
596 KB |
Output is correct |
20 |
Correct |
9 ms |
652 KB |
Output is correct |
21 |
Correct |
18 ms |
656 KB |
Output is correct |
22 |
Correct |
10 ms |
596 KB |
Output is correct |
23 |
Correct |
9 ms |
644 KB |
Output is correct |
24 |
Correct |
17 ms |
536 KB |
Output is correct |
25 |
Correct |
8 ms |
644 KB |
Output is correct |
26 |
Correct |
10 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
340 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 |
14 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
18 ms |
660 KB |
Output is correct |
19 |
Correct |
8 ms |
596 KB |
Output is correct |
20 |
Correct |
9 ms |
652 KB |
Output is correct |
21 |
Correct |
18 ms |
656 KB |
Output is correct |
22 |
Correct |
10 ms |
596 KB |
Output is correct |
23 |
Correct |
9 ms |
644 KB |
Output is correct |
24 |
Correct |
17 ms |
536 KB |
Output is correct |
25 |
Correct |
8 ms |
644 KB |
Output is correct |
26 |
Correct |
10 ms |
596 KB |
Output is correct |
27 |
Correct |
691 ms |
9876 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
34 ms |
1108 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
504 ms |
7248 KB |
Output is correct |
32 |
Correct |
576 ms |
10388 KB |
Output is correct |
33 |
Correct |
570 ms |
10460 KB |
Output is correct |
34 |
Correct |
606 ms |
8424 KB |
Output is correct |
35 |
Correct |
617 ms |
10388 KB |
Output is correct |
36 |
Correct |
536 ms |
10456 KB |
Output is correct |
37 |
Correct |
675 ms |
10488 KB |
Output is correct |
38 |
Correct |
292 ms |
7296 KB |
Output is correct |
39 |
Correct |
358 ms |
7312 KB |
Output is correct |