#include <iostream>
using namespace std;
int n, m;
const int max_dim = 3*1e3 + 5;
char v[max_dim][max_dim];
int s[max_dim][max_dim];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
cin >> n >> m;
for( int i = 1; i <= n; ++i )
{
for( int j = 1; j <= m; ++j )
{
cin >> v[i][j];
}
}
for( int i = 1; i <= n; ++i )
{
int O = 0;
for( int j = m; j >= 1; --j )
{
if( v[i][j] == 'O' )
++O;
if( v[i][j] == 'J' )
{
s[i][j] = O;
}
}
}
long long cnt = 0;
for( int j = 1; j <= m; ++j )
{
int J = 0;
for( int i = 1; i <= n; ++i )
{
if( v[i][j] == 'J' )
J+=s[i][j];
if( v[i][j] == 'I' )
{
//++I;
//cout << 1 << " " << J << "\n";
cnt += J;
}
}
}
cout << cnt;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
5 ms |
4656 KB |
Output is correct |
15 |
Correct |
1 ms |
3148 KB |
Output is correct |
16 |
Correct |
2 ms |
2516 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
4920 KB |
Output is correct |
19 |
Correct |
4 ms |
4436 KB |
Output is correct |
20 |
Correct |
4 ms |
4180 KB |
Output is correct |
21 |
Correct |
8 ms |
5000 KB |
Output is correct |
22 |
Correct |
5 ms |
4564 KB |
Output is correct |
23 |
Correct |
4 ms |
4204 KB |
Output is correct |
24 |
Correct |
6 ms |
4948 KB |
Output is correct |
25 |
Correct |
4 ms |
4436 KB |
Output is correct |
26 |
Correct |
4 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
5 ms |
4656 KB |
Output is correct |
15 |
Correct |
1 ms |
3148 KB |
Output is correct |
16 |
Correct |
2 ms |
2516 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
4920 KB |
Output is correct |
19 |
Correct |
4 ms |
4436 KB |
Output is correct |
20 |
Correct |
4 ms |
4180 KB |
Output is correct |
21 |
Correct |
8 ms |
5000 KB |
Output is correct |
22 |
Correct |
5 ms |
4564 KB |
Output is correct |
23 |
Correct |
4 ms |
4204 KB |
Output is correct |
24 |
Correct |
6 ms |
4948 KB |
Output is correct |
25 |
Correct |
4 ms |
4436 KB |
Output is correct |
26 |
Correct |
4 ms |
4180 KB |
Output is correct |
27 |
Correct |
212 ms |
52672 KB |
Output is correct |
28 |
Correct |
5 ms |
15956 KB |
Output is correct |
29 |
Correct |
10 ms |
3540 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
149 ms |
43204 KB |
Output is correct |
32 |
Correct |
152 ms |
46060 KB |
Output is correct |
33 |
Correct |
136 ms |
41500 KB |
Output is correct |
34 |
Correct |
180 ms |
50200 KB |
Output is correct |
35 |
Correct |
150 ms |
47948 KB |
Output is correct |
36 |
Correct |
137 ms |
41580 KB |
Output is correct |
37 |
Correct |
231 ms |
53240 KB |
Output is correct |
38 |
Correct |
82 ms |
35996 KB |
Output is correct |
39 |
Correct |
90 ms |
31892 KB |
Output is correct |