# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
947614 | packmani | Mecho (IOI09_mecho) | C++14 | 19 ms | 28332 KiB |
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 int
int n,m;
string s[3005];
int suff_o[3005][3005];
int suff_i[3005][3005];
int sum;
int32_t main()
{
cin >> n >> m;
for(int i=0;i<n;i++)
cin >> s[i];
for(int i=0;i<n;i++)
{
for(int j=m-1;j>0;j--)
{
suff_o[i][j-1]=suff_o[i][j];
if(s[i][j]=='O') suff_o[i][j-1]++;
}
}
for(int i=0;i<m;i++)
{
for(int j=n-1;j>0;j--)
{
suff_i[j-1][i]=suff_i[j][i];
if(s[j][i]=='I') suff_i[j-1][i]++;
}
}
sum=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='J')
{
sum+=suff_i[i][j]*suff_o[i][j];
}
}
}
cout << sum;
/*for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout << suff_o[i][j] << ' ';
}
cout << '\n';
}
cout << '\n';
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout << suff_i[i][j] << ' ';
}
cout << '\n';
}*/
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |