#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 + 20;
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)
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
111 ms |
215060 KB |
Output is correct |
2 |
Correct |
118 ms |
214816 KB |
Output is correct |
3 |
Correct |
107 ms |
215064 KB |
Output is correct |
4 |
Correct |
108 ms |
214888 KB |
Output is correct |
5 |
Correct |
105 ms |
215204 KB |
Output is correct |
6 |
Correct |
109 ms |
215028 KB |
Output is correct |
7 |
Correct |
106 ms |
215100 KB |
Output is correct |
8 |
Correct |
107 ms |
215152 KB |
Output is correct |
9 |
Correct |
112 ms |
215036 KB |
Output is correct |
10 |
Correct |
103 ms |
215012 KB |
Output is correct |
11 |
Correct |
116 ms |
215080 KB |
Output is correct |
12 |
Correct |
115 ms |
214864 KB |
Output is correct |
13 |
Correct |
103 ms |
214868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
111 ms |
215060 KB |
Output is correct |
2 |
Correct |
118 ms |
214816 KB |
Output is correct |
3 |
Correct |
107 ms |
215064 KB |
Output is correct |
4 |
Correct |
108 ms |
214888 KB |
Output is correct |
5 |
Correct |
105 ms |
215204 KB |
Output is correct |
6 |
Correct |
109 ms |
215028 KB |
Output is correct |
7 |
Correct |
106 ms |
215100 KB |
Output is correct |
8 |
Correct |
107 ms |
215152 KB |
Output is correct |
9 |
Correct |
112 ms |
215036 KB |
Output is correct |
10 |
Correct |
103 ms |
215012 KB |
Output is correct |
11 |
Correct |
116 ms |
215080 KB |
Output is correct |
12 |
Correct |
115 ms |
214864 KB |
Output is correct |
13 |
Correct |
103 ms |
214868 KB |
Output is correct |
14 |
Correct |
111 ms |
216808 KB |
Output is correct |
15 |
Correct |
113 ms |
215096 KB |
Output is correct |
16 |
Correct |
112 ms |
216548 KB |
Output is correct |
17 |
Correct |
116 ms |
215080 KB |
Output is correct |
18 |
Correct |
117 ms |
216644 KB |
Output is correct |
19 |
Correct |
131 ms |
215708 KB |
Output is correct |
20 |
Correct |
103 ms |
216700 KB |
Output is correct |
21 |
Correct |
107 ms |
216768 KB |
Output is correct |
22 |
Correct |
104 ms |
216820 KB |
Output is correct |
23 |
Correct |
100 ms |
216744 KB |
Output is correct |
24 |
Correct |
119 ms |
218144 KB |
Output is correct |
25 |
Correct |
119 ms |
215948 KB |
Output is correct |
26 |
Correct |
131 ms |
216856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
111 ms |
215060 KB |
Output is correct |
2 |
Correct |
118 ms |
214816 KB |
Output is correct |
3 |
Correct |
107 ms |
215064 KB |
Output is correct |
4 |
Correct |
108 ms |
214888 KB |
Output is correct |
5 |
Correct |
105 ms |
215204 KB |
Output is correct |
6 |
Correct |
109 ms |
215028 KB |
Output is correct |
7 |
Correct |
106 ms |
215100 KB |
Output is correct |
8 |
Correct |
107 ms |
215152 KB |
Output is correct |
9 |
Correct |
112 ms |
215036 KB |
Output is correct |
10 |
Correct |
103 ms |
215012 KB |
Output is correct |
11 |
Correct |
116 ms |
215080 KB |
Output is correct |
12 |
Correct |
115 ms |
214864 KB |
Output is correct |
13 |
Correct |
103 ms |
214868 KB |
Output is correct |
14 |
Correct |
111 ms |
216808 KB |
Output is correct |
15 |
Correct |
113 ms |
215096 KB |
Output is correct |
16 |
Correct |
112 ms |
216548 KB |
Output is correct |
17 |
Correct |
116 ms |
215080 KB |
Output is correct |
18 |
Correct |
117 ms |
216644 KB |
Output is correct |
19 |
Correct |
131 ms |
215708 KB |
Output is correct |
20 |
Correct |
103 ms |
216700 KB |
Output is correct |
21 |
Correct |
107 ms |
216768 KB |
Output is correct |
22 |
Correct |
104 ms |
216820 KB |
Output is correct |
23 |
Correct |
100 ms |
216744 KB |
Output is correct |
24 |
Correct |
119 ms |
218144 KB |
Output is correct |
25 |
Correct |
119 ms |
215948 KB |
Output is correct |
26 |
Correct |
131 ms |
216856 KB |
Output is correct |
27 |
Correct |
334 ms |
266832 KB |
Output is correct |
28 |
Correct |
109 ms |
215328 KB |
Output is correct |
29 |
Correct |
115 ms |
222504 KB |
Output is correct |
30 |
Correct |
121 ms |
215248 KB |
Output is correct |
31 |
Correct |
283 ms |
266408 KB |
Output is correct |
32 |
Correct |
324 ms |
244996 KB |
Output is correct |
33 |
Correct |
342 ms |
268080 KB |
Output is correct |
34 |
Correct |
319 ms |
267776 KB |
Output is correct |
35 |
Correct |
359 ms |
267028 KB |
Output is correct |
36 |
Correct |
327 ms |
267692 KB |
Output is correct |
37 |
Runtime error |
317 ms |
274432 KB |
Execution killed with signal 9 |
38 |
Halted |
0 ms |
0 KB |
- |