#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long
#define inf ((int)1e18)
#define N 3005
using namespace std;
string arr[N];
int icnt[N];
int32_t main(){
fast
int h, w;
cin>>h>>w;
for(int i=1; i <= h; i++){
cin>>arr[i];
arr[i]=" "+arr[i];
}
int ans=0;
for(int i=h; i > 0; i--){
int ocnt=0;
for(int j=w; j > 0; j--){
if(arr[i][j] == 'O'){
ocnt++;
}
if(arr[i][j] == 'I'){
icnt[i]++;
}
if(arr[i][j] == 'J'){
ans+=icnt[i]*ocnt;
}
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |