#include<bits/stdc++.h>
using namespace std;
char ma[3001][3001];
vector <pair<long long,long long >> di;
int main(){
long long n,m,i,j,ans=0;
cin>>n>>m;
string s;
for( i=0;i<n;i++){
cin>>s;
for( j=0;j<m;j++)
ma[i][j]=s[j];
}
for(i=0;i<n;i++){
for(int j=0;j<m;j++){
if(ma[i][j]=='J')
di.push_back({i,j});
}
}
for(pair<int,int> x:di){
long long tw=x.first;
long long on=x.second;
long long s1=0,s2=0;
for(i=on+1;i<m;i++){
if(ma[tw][i]=='O')
s1++;
}
for(i=tw+1;i<n;i++){
if(ma[i][on]=='I')
s2++;
}
ans+=s1*s2;
}
cout<<ans;
return 0;
}
# |
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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
28 ms |
2892 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
18 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
41 ms |
3912 KB |
Output is correct |
19 |
Correct |
14 ms |
2384 KB |
Output is correct |
20 |
Correct |
49 ms |
3912 KB |
Output is correct |
21 |
Correct |
39 ms |
3912 KB |
Output is correct |
22 |
Correct |
44 ms |
3912 KB |
Output is correct |
23 |
Correct |
47 ms |
3912 KB |
Output is correct |
24 |
Correct |
46 ms |
3912 KB |
Output is correct |
25 |
Correct |
15 ms |
2384 KB |
Output is correct |
26 |
Correct |
47 ms |
3912 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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
28 ms |
2892 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
18 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
41 ms |
3912 KB |
Output is correct |
19 |
Correct |
14 ms |
2384 KB |
Output is correct |
20 |
Correct |
49 ms |
3912 KB |
Output is correct |
21 |
Correct |
39 ms |
3912 KB |
Output is correct |
22 |
Correct |
44 ms |
3912 KB |
Output is correct |
23 |
Correct |
47 ms |
3912 KB |
Output is correct |
24 |
Correct |
46 ms |
3912 KB |
Output is correct |
25 |
Correct |
15 ms |
2384 KB |
Output is correct |
26 |
Correct |
47 ms |
3912 KB |
Output is correct |
27 |
Execution timed out |
1091 ms |
74900 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |