#include <bits/stdc++.h>
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
int N = 3e3 + 7;
signed main()
{
int h, w; cin >> h >> w;
vii a(N, vi(N)), b(N, vi(N));
vpii J(N);
vii gr(N, vi(N));
for (int i = 1; i <= h; i++)
{
string s; cin >> s;
s = "$" + s;
for (int j = 1; j <= w; j++)
{
gr[i][j] = s[j];
if (s[j] == 'J') J.pb({i, j});
}
}
for (int i = h; i >= 1; i--)
{
for (int j = w; j >= 1; j--)
{
a[i][j] = a[i][j + 1] + (gr[i][j] == 'O');
b[i][j] = b[i + 1][j] + (gr[i][j] == 'I');
}
}
int ans = 0;
for (auto [i, j] : J)
{
ans += a[i][j] * b[i][j];
}
cout << ans;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:47:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
47 | for (auto [i, j] : J)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
213072 KB |
Output is correct |
2 |
Correct |
89 ms |
213020 KB |
Output is correct |
3 |
Correct |
95 ms |
212988 KB |
Output is correct |
4 |
Correct |
91 ms |
213120 KB |
Output is correct |
5 |
Correct |
94 ms |
213048 KB |
Output is correct |
6 |
Correct |
92 ms |
213076 KB |
Output is correct |
7 |
Correct |
103 ms |
213096 KB |
Output is correct |
8 |
Correct |
92 ms |
213080 KB |
Output is correct |
9 |
Correct |
92 ms |
213020 KB |
Output is correct |
10 |
Correct |
93 ms |
213072 KB |
Output is correct |
11 |
Correct |
88 ms |
213240 KB |
Output is correct |
12 |
Correct |
90 ms |
212912 KB |
Output is correct |
13 |
Correct |
92 ms |
213120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
213072 KB |
Output is correct |
2 |
Correct |
89 ms |
213020 KB |
Output is correct |
3 |
Correct |
95 ms |
212988 KB |
Output is correct |
4 |
Correct |
91 ms |
213120 KB |
Output is correct |
5 |
Correct |
94 ms |
213048 KB |
Output is correct |
6 |
Correct |
92 ms |
213076 KB |
Output is correct |
7 |
Correct |
103 ms |
213096 KB |
Output is correct |
8 |
Correct |
92 ms |
213080 KB |
Output is correct |
9 |
Correct |
92 ms |
213020 KB |
Output is correct |
10 |
Correct |
93 ms |
213072 KB |
Output is correct |
11 |
Correct |
88 ms |
213240 KB |
Output is correct |
12 |
Correct |
90 ms |
212912 KB |
Output is correct |
13 |
Correct |
92 ms |
213120 KB |
Output is correct |
14 |
Correct |
94 ms |
214556 KB |
Output is correct |
15 |
Correct |
94 ms |
213164 KB |
Output is correct |
16 |
Correct |
92 ms |
214632 KB |
Output is correct |
17 |
Correct |
97 ms |
213068 KB |
Output is correct |
18 |
Correct |
104 ms |
214560 KB |
Output is correct |
19 |
Correct |
99 ms |
213908 KB |
Output is correct |
20 |
Correct |
117 ms |
214552 KB |
Output is correct |
21 |
Correct |
115 ms |
214708 KB |
Output is correct |
22 |
Correct |
91 ms |
214592 KB |
Output is correct |
23 |
Correct |
95 ms |
214652 KB |
Output is correct |
24 |
Correct |
98 ms |
216960 KB |
Output is correct |
25 |
Correct |
90 ms |
213908 KB |
Output is correct |
26 |
Correct |
92 ms |
214552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
213072 KB |
Output is correct |
2 |
Correct |
89 ms |
213020 KB |
Output is correct |
3 |
Correct |
95 ms |
212988 KB |
Output is correct |
4 |
Correct |
91 ms |
213120 KB |
Output is correct |
5 |
Correct |
94 ms |
213048 KB |
Output is correct |
6 |
Correct |
92 ms |
213076 KB |
Output is correct |
7 |
Correct |
103 ms |
213096 KB |
Output is correct |
8 |
Correct |
92 ms |
213080 KB |
Output is correct |
9 |
Correct |
92 ms |
213020 KB |
Output is correct |
10 |
Correct |
93 ms |
213072 KB |
Output is correct |
11 |
Correct |
88 ms |
213240 KB |
Output is correct |
12 |
Correct |
90 ms |
212912 KB |
Output is correct |
13 |
Correct |
92 ms |
213120 KB |
Output is correct |
14 |
Correct |
94 ms |
214556 KB |
Output is correct |
15 |
Correct |
94 ms |
213164 KB |
Output is correct |
16 |
Correct |
92 ms |
214632 KB |
Output is correct |
17 |
Correct |
97 ms |
213068 KB |
Output is correct |
18 |
Correct |
104 ms |
214560 KB |
Output is correct |
19 |
Correct |
99 ms |
213908 KB |
Output is correct |
20 |
Correct |
117 ms |
214552 KB |
Output is correct |
21 |
Correct |
115 ms |
214708 KB |
Output is correct |
22 |
Correct |
91 ms |
214592 KB |
Output is correct |
23 |
Correct |
95 ms |
214652 KB |
Output is correct |
24 |
Correct |
98 ms |
216960 KB |
Output is correct |
25 |
Correct |
90 ms |
213908 KB |
Output is correct |
26 |
Correct |
92 ms |
214552 KB |
Output is correct |
27 |
Correct |
313 ms |
262476 KB |
Output is correct |
28 |
Correct |
97 ms |
213336 KB |
Output is correct |
29 |
Correct |
102 ms |
219208 KB |
Output is correct |
30 |
Correct |
90 ms |
213200 KB |
Output is correct |
31 |
Correct |
247 ms |
262500 KB |
Output is correct |
32 |
Correct |
269 ms |
237480 KB |
Output is correct |
33 |
Correct |
307 ms |
262452 KB |
Output is correct |
34 |
Correct |
301 ms |
262424 KB |
Output is correct |
35 |
Correct |
302 ms |
261924 KB |
Output is correct |
36 |
Correct |
317 ms |
261456 KB |
Output is correct |
37 |
Runtime error |
253 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |