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 <iostream>
using namespace std;
int n, m;
const int max_dim = 3*1e3 + 5;
char v[max_dim][max_dim];
int s[max_dim][max_dim];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
cin >> n >> m;
for( int i = 1; i <= n; ++i )
{
for( int j = 1; j <= m; ++j )
{
cin >> v[i][j];
}
}
for( int i = 1; i <= n; ++i )
{
int O = 0;
for( int j = m; j >= 1; --j )
{
if( v[i][j] == 'O' )
++O;
if( v[i][j] == 'J' )
{
s[i][j] = O;
}
}
}
long long cnt = 0;
for( int j = 1; j <= m; ++j )
{
int J = 0;
for( int i = 1; i <= n; ++i )
{
if( v[i][j] == 'J' )
J+=s[i][j];
if( v[i][j] == 'I' )
{
//++I;
//cout << 1 << " " << J << "\n";
cnt += J;
}
}
}
cout << cnt;
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... |