#include<bits/stdc++.h>
using namespace std;
const int MAXN=3003, MAXM=3003;
char s[3010][3010]={};
long long O[MAXN][MAXM]={},I[MAXN][MAXM]={},n,m;
double ans=0;
void input()
{
cin>>n>>m;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
cin>>s[i][j];
}
void getO()
{
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
{
if (j!=1) {O[i][j]=O[i][j-1];};
if (s[i][j]=='O') {O[i][j]++;};
}
}
void getI()
{
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
{
if (i!=1) {I[i][j]=I[i-1][j];};
if (s[i][j]=='I') {I[i][j]++;};
}
}
void process()
{
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (s[i][j]=='J')
{
ans+=(I[n][j]-I[i][j])*(O[i][m]-O[i][j]);
}
}
void output()
{
cout<<ans;
}
int main()
{
//freopen("C:/TEST/stoveout.txt","r",stdin);
//freopen("C:/TEST/stoveoutout.txt","w",stdout);
input();
getO();
getI();
process();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
1656 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 KB |
Output is correct |
7 |
Incorrect |
6 ms |
1400 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
1656 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 KB |
Output is correct |
7 |
Incorrect |
6 ms |
1400 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
1656 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 KB |
Output is correct |
7 |
Incorrect |
6 ms |
1400 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |