#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int H, W;
cin>>H>>W;
vector<int> O[H];
vector<int> I[W];
vector<pii> J;
for(int i=0;i<H;i++) {
string s;
cin>>s;
for(int j=0;j<W;j++) {
if(s[j]=='O') O[i].push_back(j);
else if(s[j]=='I') I[j].push_back(i);
else J.push_back({i, j});
}
}
ll ans = 0;
for(pii j:J) {
ll o = O[j.f].end()-upper_bound(O[j.f].begin(), O[j.f].end(), j.s);
ll
i = I[j.s].end()-upper_bound(I[j.s].begin(), I[j.s].end(), j.f);
ans += i*o;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 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 |
10 ms |
1656 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1232 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
11 ms |
2380 KB |
Output is correct |
19 |
Correct |
4 ms |
1744 KB |
Output is correct |
20 |
Correct |
5 ms |
1684 KB |
Output is correct |
21 |
Correct |
11 ms |
2508 KB |
Output is correct |
22 |
Correct |
7 ms |
2244 KB |
Output is correct |
23 |
Correct |
5 ms |
1968 KB |
Output is correct |
24 |
Correct |
12 ms |
2180 KB |
Output is correct |
25 |
Correct |
4 ms |
1944 KB |
Output is correct |
26 |
Correct |
5 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 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 |
10 ms |
1656 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1232 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
11 ms |
2380 KB |
Output is correct |
19 |
Correct |
4 ms |
1744 KB |
Output is correct |
20 |
Correct |
5 ms |
1684 KB |
Output is correct |
21 |
Correct |
11 ms |
2508 KB |
Output is correct |
22 |
Correct |
7 ms |
2244 KB |
Output is correct |
23 |
Correct |
5 ms |
1968 KB |
Output is correct |
24 |
Correct |
12 ms |
2180 KB |
Output is correct |
25 |
Correct |
4 ms |
1944 KB |
Output is correct |
26 |
Correct |
5 ms |
1912 KB |
Output is correct |
27 |
Correct |
454 ms |
59680 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
15 ms |
5452 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
336 ms |
43716 KB |
Output is correct |
32 |
Correct |
161 ms |
57952 KB |
Output is correct |
33 |
Correct |
255 ms |
61824 KB |
Output is correct |
34 |
Correct |
385 ms |
60020 KB |
Output is correct |
35 |
Correct |
287 ms |
62372 KB |
Output is correct |
36 |
Correct |
241 ms |
61812 KB |
Output is correct |
37 |
Correct |
596 ms |
72536 KB |
Output is correct |
38 |
Correct |
126 ms |
40996 KB |
Output is correct |
39 |
Correct |
170 ms |
48844 KB |
Output is correct |