Submission #765534

# Submission time Handle Problem Language Result Execution time Memory
765534 2023-06-24T18:29:59 Z NK_ Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
82 ms 80740 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

template<class T> using V = vector<T>;
using str = string;
using ll = long long;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N, M; cin >> N >> M;
	V<str> A(N); for(auto& x : A) cin >> x;

	V<V<int>> I(N, V<int>(M, 0)), O(N, V<int>(M, 0));

	ll ans = 0;
	for(int i = N - 1; i >= 0; i--) for(int j = M - 1; j >= 0; j--) {
		I[i][j] = (A[i][j] == 'I');
		if (i+1 < N) I[i][j] += I[i+1][j];

		O[i][j] = (A[i][j] == 'O');
		if (j+1 < M) O[i][j] += O[i][j+1];

		if (A[i][j] == 'J') ans += O[i][j] * 1LL * I[i][j];
	}

	cout << ans << nl;

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 2 ms 2004 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 1492 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 2 ms 2516 KB Output is correct
19 Correct 2 ms 2388 KB Output is correct
20 Correct 2 ms 2516 KB Output is correct
21 Correct 2 ms 2516 KB Output is correct
22 Correct 2 ms 2388 KB Output is correct
23 Correct 2 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 3 ms 2388 KB Output is correct
26 Correct 2 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 2 ms 2004 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 1492 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 2 ms 2516 KB Output is correct
19 Correct 2 ms 2388 KB Output is correct
20 Correct 2 ms 2516 KB Output is correct
21 Correct 2 ms 2516 KB Output is correct
22 Correct 2 ms 2388 KB Output is correct
23 Correct 2 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 3 ms 2388 KB Output is correct
26 Correct 2 ms 2516 KB Output is correct
27 Correct 73 ms 76228 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 5 ms 6100 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 54 ms 56112 KB Output is correct
32 Correct 59 ms 80212 KB Output is correct
33 Correct 59 ms 80540 KB Output is correct
34 Correct 63 ms 65092 KB Output is correct
35 Correct 64 ms 80252 KB Output is correct
36 Correct 59 ms 80468 KB Output is correct
37 Correct 82 ms 80740 KB Output is correct
38 Correct 42 ms 55716 KB Output is correct
39 Correct 43 ms 55900 KB Output is correct