#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
int 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];
int 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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
19 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1508 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
7 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
19 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1508 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
7 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
22 ms |
7296 KB |
Output is correct |
15 |
Correct |
8 ms |
4964 KB |
Output is correct |
16 |
Correct |
14 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
29 ms |
7800 KB |
Output is correct |
19 |
Correct |
22 ms |
7672 KB |
Output is correct |
20 |
Incorrect |
25 ms |
7544 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
19 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1508 KB |
Output is correct |
10 |
Correct |
4 ms |
1408 KB |
Output is correct |
11 |
Correct |
7 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
22 ms |
7296 KB |
Output is correct |
15 |
Correct |
8 ms |
4964 KB |
Output is correct |
16 |
Correct |
14 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
29 ms |
7800 KB |
Output is correct |
19 |
Correct |
22 ms |
7672 KB |
Output is correct |
20 |
Incorrect |
25 ms |
7544 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |