Submission #531972

# Submission time Handle Problem Language Result Execution time Memory
531972 2022-03-02T02:10:11 Z abc864197532 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
159 ms 89608 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l)
		cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0)
#endif

int main () {
	owo;
	int n, m;
	cin >> n >> m;
	vector <string> s(n);
	vector <vector <int>> down(n, vector <int> (m, 0)), r(n, vector <int> (m, 0));
	for (int i = 0; i < n; ++i)
		cin >> s[i];
	for (int i = n - 1; ~i; --i) {
		for (int j = 0; j < m; ++j) {
			down[i][j] = (i + 1 < n ? down[i + 1][j] : 0) + (s[i][j] == 'I');
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = m - 1; ~j; --j) {
			r[i][j] = (j + 1 < m ? r[i][j + 1] : 0) + (s[i][j] == 'O');
		}
	}
	lli ans = 0;
	for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (s[i][j] == 'J')
		ans += down[i][j] * r[i][j];
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 4 ms 2240 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 3 ms 1600 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 5 ms 2764 KB Output is correct
19 Correct 3 ms 2644 KB Output is correct
20 Correct 3 ms 2752 KB Output is correct
21 Correct 4 ms 2812 KB Output is correct
22 Correct 4 ms 2604 KB Output is correct
23 Correct 3 ms 2748 KB Output is correct
24 Correct 4 ms 2744 KB Output is correct
25 Correct 3 ms 2720 KB Output is correct
26 Correct 3 ms 2884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 4 ms 2240 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 3 ms 1600 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 5 ms 2764 KB Output is correct
19 Correct 3 ms 2644 KB Output is correct
20 Correct 3 ms 2752 KB Output is correct
21 Correct 4 ms 2812 KB Output is correct
22 Correct 4 ms 2604 KB Output is correct
23 Correct 3 ms 2748 KB Output is correct
24 Correct 4 ms 2744 KB Output is correct
25 Correct 3 ms 2720 KB Output is correct
26 Correct 3 ms 2884 KB Output is correct
27 Correct 110 ms 84468 KB Output is correct
28 Correct 1 ms 708 KB Output is correct
29 Correct 8 ms 6716 KB Output is correct
30 Correct 1 ms 452 KB Output is correct
31 Correct 92 ms 62188 KB Output is correct
32 Correct 92 ms 88884 KB Output is correct
33 Correct 89 ms 89392 KB Output is correct
34 Correct 106 ms 72132 KB Output is correct
35 Correct 98 ms 88960 KB Output is correct
36 Correct 89 ms 89196 KB Output is correct
37 Correct 159 ms 89608 KB Output is correct
38 Correct 91 ms 61728 KB Output is correct
39 Correct 62 ms 61968 KB Output is correct