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 N = 3e3 + 5;
int satir[N][N], sutun[N][N];
char grid[N][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> grid[i][j];
}
}
for(int j = m - 1; j >= 0; j--)
{
for(int i = n - 1; i >= 0; i--)
{
sutun[i][j] = sutun[i + 1][j];
if(grid[i][j] == 'I')
sutun[i][j]++;
}
}
for(int i = n - 1; i >= 0; i--)
{
for(int j = m - 1; j >= 0; j--)
{
satir[i][j] = satir[i][j + 1];
if(grid[i][j] == 'O')
satir[i][j]++;
}
}
long long cevap = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(grid[i][j] == 'J')
{
cevap += satir[i][j] * sutun[i][j];
}
}
}
cout << cevap << '\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... |