#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pii pair<int,int>
typedef long long int ll;
vector<pii> jj;
map<int,vector<int> > o;
map<int,vector<int> > l;
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n,m; cin>>n>>m;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
char c;
cin>>c;
if(c=='J') jj.push_back({i,j});
else if(c=='O') o[i].push_back(j);
else if(c=='I') l[j].push_back(i);
}
}
ll lol=0;
for(auto a:jj) {
int f=a.first;
int s=a.second;
//cout<<f<<" "<<s<<endl;
/*for(int z:l[s]) {
cout<<z<<" "<<s<<endl;
}*/
ll ans=o[f].end()-upper_bound(o[f].begin(),o[f].end(),s);
ll anss=l[s].end()-upper_bound(l[s].begin(),l[s].end(),f);
//cout<<ans<<" "<<anss<<endl;
lol+=ans*anss;
//break;
}
cout<<lol<<endl;
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 |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
3 ms |
376 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 |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
35 ms |
1904 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
20 ms |
1396 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
46 ms |
2672 KB |
Output is correct |
19 |
Correct |
21 ms |
2040 KB |
Output is correct |
20 |
Correct |
30 ms |
1980 KB |
Output is correct |
21 |
Correct |
46 ms |
2672 KB |
Output is correct |
22 |
Correct |
36 ms |
2348 KB |
Output is correct |
23 |
Correct |
30 ms |
1976 KB |
Output is correct |
24 |
Correct |
48 ms |
2284 KB |
Output is correct |
25 |
Correct |
20 ms |
2036 KB |
Output is correct |
26 |
Correct |
30 ms |
1976 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 |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
420 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
35 ms |
1904 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
20 ms |
1396 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
46 ms |
2672 KB |
Output is correct |
19 |
Correct |
21 ms |
2040 KB |
Output is correct |
20 |
Correct |
30 ms |
1980 KB |
Output is correct |
21 |
Correct |
46 ms |
2672 KB |
Output is correct |
22 |
Correct |
36 ms |
2348 KB |
Output is correct |
23 |
Correct |
30 ms |
1976 KB |
Output is correct |
24 |
Correct |
48 ms |
2284 KB |
Output is correct |
25 |
Correct |
20 ms |
2036 KB |
Output is correct |
26 |
Correct |
30 ms |
1976 KB |
Output is correct |
27 |
Execution timed out |
1067 ms |
62840 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |