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;
const int MAXN = 3010;
int grid[MAXN][MAXN];
int ing[MAXN][MAXN],orb[MAXN][MAXN];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int H,W; cin >> H >> W; //count for every J how many O's are in the row after it and how many I's are in the column after it
for(int i = 0;i<H;++i){
string s; cin >> s;
for(int j = 0;j<W;++j){
grid[i][j] = s[j];
}
}
for(int i = 0;i<H;++i){
int cnt = 0;
for(int j = W-1;j>=0;--j){
if(grid[i][j] == 'J'){
orb[i][j] = cnt;
}
else if(grid[i][j] == 'O'){
cnt++;
}
}
}
for(int i = 0;i<W;++i){
int cnt = 0;
for(int j = H-1;j>=0;--j){
if(grid[j][i] == 'J'){
ing[j][i] = cnt;
}
else if(grid[j][i] == 'I'){
cnt++;
}
}
}
int ans = 0;
for(int i = 0;i<H;++i){
for(int j = 0;j<W;++j){
if(grid[i][j] == 'J'){
//cout << ing[i][j] << " " << orb[i][j] << "\n";
ans += ing[i][j]*orb[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... |