#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
const int maxn=3005;
int h,w,a[maxn][maxn],b[maxn][maxn];
string s[maxn];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> h >> w;
for(int i=0;i<h;i++){
cin >> s[i];
}
int ans=0;
for(int i=h-1;i>=0;i--){
for(int j=w-1;j>=0;j--){
a[i][j]=a[i+1][j];
b[i][j]=b[i][j+1];
if(s[i][j]=='I') a[i][j]++;
else if(s[i][j]=='O') b[i][j]++;
else ans+=a[i][j]*b[i][j];
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1336 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1336 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
5 ms |
9752 KB |
Output is correct |
15 |
Correct |
2 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
5080 KB |
Output is correct |
17 |
Correct |
1 ms |
652 KB |
Output is correct |
18 |
Correct |
4 ms |
11100 KB |
Output is correct |
19 |
Correct |
3 ms |
11100 KB |
Output is correct |
20 |
Incorrect |
3 ms |
10076 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1336 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
5 ms |
9752 KB |
Output is correct |
15 |
Correct |
2 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
5080 KB |
Output is correct |
17 |
Correct |
1 ms |
652 KB |
Output is correct |
18 |
Correct |
4 ms |
11100 KB |
Output is correct |
19 |
Correct |
3 ms |
11100 KB |
Output is correct |
20 |
Incorrect |
3 ms |
10076 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |