#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int h,w;
string s[3005];
cin >> h >> w;
for(int i=0;i<h;i++) cin >> s[i];
unordered_map<int,ll> rows;
unordered_map<int,ll> colum;
for(int i=0;i<h;i++){
ll x=0,y=0;
for(int j=0;j<w;j++){
if(s[i][j]=='O') x++;
if(s[j][i]=='I') y++;
}
rows[i]=x;
colum[i]=y;
// cout << "Row " << i << " " << x << endl;
// cout << "Col " << i << " " << y << endl;
}
ll ans=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(s[i][j]=='J') ans+=(rows[i]*colum[j]);
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |