#include<bits/stdc++.h>
using namespace std;
const int MAXN=3003, MAXM=3003;
string s[3010]={};
long long O[MAXN][MAXM]={},I[MAXN][MAXM]={},n,m;
long long 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()
{
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 |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Runtime error |
11 ms |
632 KB |
Execution killed with signal 7 (could be triggered by violating memory limits) |
6 |
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 |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Runtime error |
11 ms |
632 KB |
Execution killed with signal 7 (could be triggered by violating memory limits) |
6 |
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 |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Runtime error |
11 ms |
632 KB |
Execution killed with signal 7 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |