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 = 3e3 + 10;
int_fast64_t numO[maxn][maxn], numI[maxn][maxn];
int main()
{
ios::sync_with_stdio(false), cin.tie(nullptr);
char tab[maxn][maxn];
int H, W;
cin >> H >> W;
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
cin >> tab[i][j];
}
}
for(int i = 0; i < H; i++)
{
for(int j = 1; j < W; j++)
{
if(j)numO[i][j] += numO[i][j - 1];
if(tab[i][j] == 'O') numO[i][j]++;
}
}
for(int i = 0; i < W; i++)
{
for(int j = 0; j < H; j++)
{
if(j) numI[j][i] += numI[j - 1][i];
if(tab[j][i] == 'I') numI[j][i]++;
}
}
//for(int i = 0; i < H; i++) cout << numO[i][W - 1] << " \n"[i== H-1];
//for(int i = 0; i < W; i++) cout << numI[H - 1][i] << " \n"[i== W-1];
int_fast64_t cont = 0;
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
if(tab[i][j] == 'J')
{
//cout << i << " " << j << "\n";
cont += (numO[i][W - 1] - numO[i][j])*(numI[H - 1][j] -numI[i][j]);
}
}
}
cout << cont << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |