#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3+10;
int h, w;
char mat[maxn][maxn];
int sumO[maxn][maxn], sumI[maxn][maxn];
int main()
{
cin >> h >> w;
for(int i = 1 ; i <= h ; ++i)
for(int j = 1 ; j <= w; ++j)
cin >> mat[i][j];
// make a sum of eche O
for(int i = 1 ; i <= h ; ++i)
{
for(int j = 1 ; j <= w; ++j)
{
sumO[i][j] = sumO[i][j - 1];
if(mat[i][j] == 'O')
sumO[i][j]++;
}
}
for(int i = 1 ; i <= w ; ++i)
{
for(int j = 1 ; j <= h; ++j)
{
sumI[j][i] = sumI[j - 1][i];
if(mat[j][i] == 'I')
sumI[j][i]++;
}
}
int resp = 0;
for(int i = 1 ; i <= h ; ++i)
{
for(int j = 1 ; j <= w; ++j)
{
if(mat[i][j] == 'J')
{
int O = sumO[i][w] - sumO[i][j];
int I = sumI[h][j] - sumI[i - 1][j];
//cout << i << " " << j << " " << O << " " << I << "\n" ;
resp += (O*I);
}
}
}
cout << resp << "\n";
/*for(int i = 1 ; i <= h ; ++i)
{
for(int j = 1 ; j <= w; ++j)
{
cout << sumO[i][j] <<" ";
}
cout << "\n";
}
cout << "\n";
for(int i = 1 ; i <= h ; ++i)
{
for(int j = 1 ; j <= w; ++j)
{
cout << sumI[i][j] <<" ";
}
cout << "\n";
}*/
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 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 |
384 KB |
Output is correct |
5 |
Correct |
4 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 |
5 ms |
1508 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
7 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 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 |
384 KB |
Output is correct |
5 |
Correct |
4 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 |
5 ms |
1508 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
7 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
7396 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
16 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
25 ms |
7908 KB |
Output is correct |
19 |
Correct |
35 ms |
7928 KB |
Output is correct |
20 |
Incorrect |
27 ms |
7884 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 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 |
384 KB |
Output is correct |
5 |
Correct |
4 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 |
5 ms |
1508 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
7 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
7396 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
16 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
25 ms |
7908 KB |
Output is correct |
19 |
Correct |
35 ms |
7928 KB |
Output is correct |
20 |
Incorrect |
27 ms |
7884 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |