#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H, W;
char grid[3000][3000];
int ingots[3000] = {0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> H >> W;
for (int i = H - 1; i >= 0; i--)
for (int j = W - 1; j >= 0; j--)
cin >> grid[i][j];
ll res = 0;
for (int i = 1; i < H; i++)
{
int orbs = 0;
for (int j = 1; j < W; j++)
{
orbs += (grid[i][j-1] == 'O');
ingots[j] += (grid[i-1][j] == 'I');
res += (grid[i][j] == 'J') * orbs * ingots[j];
}
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
608 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
608 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
1872 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
4 ms |
1104 KB |
Output is correct |
17 |
Correct |
2 ms |
328 KB |
Output is correct |
18 |
Correct |
6 ms |
2004 KB |
Output is correct |
19 |
Correct |
4 ms |
2036 KB |
Output is correct |
20 |
Correct |
4 ms |
2004 KB |
Output is correct |
21 |
Correct |
5 ms |
2004 KB |
Output is correct |
22 |
Correct |
4 ms |
2004 KB |
Output is correct |
23 |
Correct |
4 ms |
1876 KB |
Output is correct |
24 |
Correct |
5 ms |
2004 KB |
Output is correct |
25 |
Correct |
4 ms |
2004 KB |
Output is correct |
26 |
Correct |
4 ms |
1964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
608 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
1872 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
4 ms |
1104 KB |
Output is correct |
17 |
Correct |
2 ms |
328 KB |
Output is correct |
18 |
Correct |
6 ms |
2004 KB |
Output is correct |
19 |
Correct |
4 ms |
2036 KB |
Output is correct |
20 |
Correct |
4 ms |
2004 KB |
Output is correct |
21 |
Correct |
5 ms |
2004 KB |
Output is correct |
22 |
Correct |
4 ms |
2004 KB |
Output is correct |
23 |
Correct |
4 ms |
1876 KB |
Output is correct |
24 |
Correct |
5 ms |
2004 KB |
Output is correct |
25 |
Correct |
4 ms |
2004 KB |
Output is correct |
26 |
Correct |
4 ms |
1964 KB |
Output is correct |
27 |
Correct |
131 ms |
17364 KB |
Output is correct |
28 |
Correct |
5 ms |
7128 KB |
Output is correct |
29 |
Correct |
10 ms |
1616 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
88 ms |
13720 KB |
Output is correct |
32 |
Correct |
120 ms |
17832 KB |
Output is correct |
33 |
Correct |
116 ms |
17824 KB |
Output is correct |
34 |
Correct |
103 ms |
15912 KB |
Output is correct |
35 |
Correct |
135 ms |
17824 KB |
Output is correct |
36 |
Correct |
127 ms |
17816 KB |
Output is correct |
37 |
Correct |
117 ms |
17808 KB |
Output is correct |
38 |
Correct |
83 ms |
13688 KB |
Output is correct |
39 |
Correct |
85 ms |
13680 KB |
Output is correct |