This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int sz = 3005;
char a[sz][sz];
int s[3][sz][sz];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("JOI19_ho_t1.inp","r",stdin);
//freopen("JOI19_ho_t1.out","w",stdout);
int n, m;
cin>>n>>m;
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
cin>>a[i][j];
s[0][i][j] = s[0][i][j-1] + (a[i][j] == 'O');
s[1][i][j] = s[1][i-1][j] + (a[i][j] == 'I');
}
}
int ans = 0;
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
if(a[i][j] == 'J'){
int x = s[1][n][j] - s[1][i][j];
int y = s[0][i][m] - s[0][i][j];
ans += (x * y);
}
}
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |