Submission #382582

# Submission time Handle Problem Language Result Execution time Memory
382582 2021-03-27T19:25:07 Z aryan12 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
268 ms 16776 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

void Solve() {
	int h, w;
	cin >> h >> w;
	char a[h][w];
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	int orbRow[h], ingotCol[w];
	for(int i = 0; i < h; i++) {
		orbRow[i] = 0;
	}
	for(int i = 0; i < w; i++) {
		ingotCol[i] = 0;
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i][j] == 'O') {
				orbRow[i]++;
			}
			if(a[i][j] == 'I') {
				ingotCol[j]++;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i][j] == 'J') {
				ans += orbRow[i] * ingotCol[j];
			}
			else if(a[i][j] == 'O') {
				orbRow[i]--;
			}
			else {
				ingotCol[j]--;
			}
		}
	}
	cout << ans << "\n";
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	Solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 7 ms 896 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 8 ms 876 KB Output is correct
19 Correct 5 ms 748 KB Output is correct
20 Correct 6 ms 876 KB Output is correct
21 Correct 9 ms 876 KB Output is correct
22 Correct 6 ms 748 KB Output is correct
23 Correct 6 ms 876 KB Output is correct
24 Correct 9 ms 876 KB Output is correct
25 Correct 7 ms 748 KB Output is correct
26 Correct 6 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 7 ms 896 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 8 ms 876 KB Output is correct
19 Correct 5 ms 748 KB Output is correct
20 Correct 6 ms 876 KB Output is correct
21 Correct 9 ms 876 KB Output is correct
22 Correct 6 ms 748 KB Output is correct
23 Correct 6 ms 876 KB Output is correct
24 Correct 9 ms 876 KB Output is correct
25 Correct 7 ms 748 KB Output is correct
26 Correct 6 ms 876 KB Output is correct
27 Correct 250 ms 16364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 12 ms 1644 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 183 ms 12652 KB Output is correct
32 Correct 190 ms 16620 KB Output is correct
33 Correct 162 ms 16620 KB Output is correct
34 Correct 229 ms 14572 KB Output is correct
35 Correct 163 ms 16620 KB Output is correct
36 Correct 155 ms 16620 KB Output is correct
37 Correct 268 ms 16776 KB Output is correct
38 Correct 118 ms 12524 KB Output is correct
39 Correct 110 ms 12524 KB Output is correct