#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
long long numO[maxn][maxn], numI[maxn][maxn];
int main()
{
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];
long long 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 |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1536 KB |
Output is correct |
14 |
Correct |
25 ms |
8824 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
14 ms |
5248 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
27 ms |
9728 KB |
Output is correct |
19 |
Correct |
33 ms |
9592 KB |
Output is correct |
20 |
Correct |
27 ms |
9528 KB |
Output is correct |
21 |
Correct |
31 ms |
9728 KB |
Output is correct |
22 |
Correct |
30 ms |
9592 KB |
Output is correct |
23 |
Correct |
31 ms |
9600 KB |
Output is correct |
24 |
Correct |
31 ms |
9748 KB |
Output is correct |
25 |
Correct |
28 ms |
9600 KB |
Output is correct |
26 |
Correct |
29 ms |
9600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
3 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1536 KB |
Output is correct |
14 |
Correct |
25 ms |
8824 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
14 ms |
5248 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
27 ms |
9728 KB |
Output is correct |
19 |
Correct |
33 ms |
9592 KB |
Output is correct |
20 |
Correct |
27 ms |
9528 KB |
Output is correct |
21 |
Correct |
31 ms |
9728 KB |
Output is correct |
22 |
Correct |
30 ms |
9592 KB |
Output is correct |
23 |
Correct |
31 ms |
9600 KB |
Output is correct |
24 |
Correct |
31 ms |
9748 KB |
Output is correct |
25 |
Correct |
28 ms |
9600 KB |
Output is correct |
26 |
Correct |
29 ms |
9600 KB |
Output is correct |
27 |
Execution timed out |
1016 ms |
150636 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |