Submission #390324

# Submission time Handle Problem Language Result Execution time Memory
390324 2021-04-15T20:28:16 Z idontreallyknow Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
343 ms 89408 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";};
template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";};
template<class T> void pv(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) cerr << *i << " "; cerr << "]\n";}
void _print() {cerr << "]\n";}
template<class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = [", _print(x)
#define fi first
#define se second
#define SZ(x) (int)((x).size())
#define pii pair<int,int>
string grid[3005];
int o[3005][3005], i[3005][3005];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for (int q = 0; q < n; q++) cin >> grid[q];
	for (int q = 0; q < m; q++) {
		for (int w = n-1; w >= 0; w--) {
			i[w][q] = i[w+1][q]+(grid[w][q] == 'I');
		}
	}
	for (int q = 0; q < n; q++) {
		for (int w = m-1; w >= 0; w--) {
			o[q][w] = o[q][w+1]+(grid[q][w] == 'O');
		}
	}
	ll ans = 0;
	for (int q = 0; q < n; q++) {
		for (int w = 0; w < m; w++) {
			if (grid[q][w] == 'J') {
				ans += 1LL*i[q][w]*o[q][w];
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 8 ms 6220 KB Output is correct
15 Correct 3 ms 3788 KB Output is correct
16 Correct 4 ms 3660 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 7 ms 6840 KB Output is correct
19 Correct 6 ms 6788 KB Output is correct
20 Correct 7 ms 6732 KB Output is correct
21 Correct 7 ms 6860 KB Output is correct
22 Correct 7 ms 6732 KB Output is correct
23 Correct 6 ms 6732 KB Output is correct
24 Correct 8 ms 6860 KB Output is correct
25 Correct 6 ms 6732 KB Output is correct
26 Correct 6 ms 6732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 8 ms 6220 KB Output is correct
15 Correct 3 ms 3788 KB Output is correct
16 Correct 4 ms 3660 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 7 ms 6840 KB Output is correct
19 Correct 6 ms 6788 KB Output is correct
20 Correct 7 ms 6732 KB Output is correct
21 Correct 7 ms 6860 KB Output is correct
22 Correct 7 ms 6732 KB Output is correct
23 Correct 6 ms 6732 KB Output is correct
24 Correct 8 ms 6860 KB Output is correct
25 Correct 6 ms 6732 KB Output is correct
26 Correct 6 ms 6732 KB Output is correct
27 Correct 343 ms 88384 KB Output is correct
28 Correct 12 ms 19276 KB Output is correct
29 Correct 11 ms 7756 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 235 ms 71856 KB Output is correct
32 Correct 317 ms 89260 KB Output is correct
33 Correct 309 ms 89200 KB Output is correct
34 Correct 278 ms 83484 KB Output is correct
35 Correct 315 ms 89236 KB Output is correct
36 Correct 288 ms 89156 KB Output is correct
37 Correct 334 ms 89408 KB Output is correct
38 Correct 198 ms 71852 KB Output is correct
39 Correct 198 ms 71580 KB Output is correct