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>
#define int long long
using namespace std;
const int MAXN = 3010;
string grid[MAXN];
int cntI[MAXN][MAXN], cntO[MAXN][MAXN];
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int H,W; cin >> H >> W;
for(int i = 0;i<H;++i){
cin >> grid[i];
}
for(int i = 0;i<H;++i){
int os = 0;
for(int j = W-1;j>=0;--j){
if(grid[i][j] == 'J'){
cntO[i][j] = os;
//cout << i << " " << j << " " << cntO[i][j] << "\n";
}
else if(grid[i][j] == 'O') os++;
}
}
for(int i = 0;i<W;++i){
int is = 0;
for(int j = H-1;j>=0;--j){
if(grid[j][i] == 'J'){
cntI[j][i] = is;
//cout << j << " " << i << " " << cntI[j][i] << "\n";
}
else if(grid[j][i] == 'I') is++;
}
}
int ans = 0;
for(int i = 0;i<H;++i){
for(int j = 0;j<W;++j){
if(grid[i][j] == 'J'){
//cout << i << " " << j << " " << cntI[j][i] << " " << cntO[i][j] << "\n";
ans += cntI[i][j]*cntO[i][j];
}
}
}
cout << ans << "\n";
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... |