Submission #659148

# Submission time Handle Problem Language Result Execution time Memory
659148 2022-11-16T19:24:54 Z Kenpar Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
256 ms 17980 KB
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define endl '\n'

const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll MAX = 2 * 1e5;

void solve(){
	int n,m;
	cin>>n>>m;
	char arr[n][m];
	vector<array<int,3>> cols(m), rows(n);
	for(int i = 0; i < n ;i++){
		for(int j = 0; j < m; j++){
			cin>>arr[i][j];

			if(arr[i][j] == 'J'){
				cols[j][0]++;
				rows[i][0]++;
			}else if(arr[i][j] == 'O'){
				cols[j][1]++;
				rows[i][1]++;
			}else{
				cols[j][2]++;
				rows[i][2]++;
			}
		}
	}

	ll ans = 0;

	for(int i = 0; i < n ;i++){
		for(int j = 0; j < m; j++){
			if(arr[i][j] == 'J'){
				cols[j][0]--;
				rows[i][0]--;

				ans+= rows[i][1] * cols[j][2];
			}else if(arr[i][j] == 'O'){
				cols[j][1]--;
				rows[i][1]--;
			}else{
				cols[j][2]--;
				rows[i][2]--;
			}
		}
	}

	cout<<ans;
}


int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(NULL);
	int t = 1;

	//cin >> t;

	while(t--){
		//cout<<"Case #"<<t<<" > "<<endl;
		solve();

		cout<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 588 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 620 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 5 ms 724 KB Output is correct
20 Correct 5 ms 716 KB Output is correct
21 Correct 8 ms 724 KB Output is correct
22 Correct 6 ms 724 KB Output is correct
23 Correct 5 ms 812 KB Output is correct
24 Correct 7 ms 724 KB Output is correct
25 Correct 5 ms 672 KB Output is correct
26 Correct 5 ms 804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 588 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 620 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 8 ms 768 KB Output is correct
19 Correct 5 ms 724 KB Output is correct
20 Correct 5 ms 716 KB Output is correct
21 Correct 8 ms 724 KB Output is correct
22 Correct 6 ms 724 KB Output is correct
23 Correct 5 ms 812 KB Output is correct
24 Correct 7 ms 724 KB Output is correct
25 Correct 5 ms 672 KB Output is correct
26 Correct 5 ms 804 KB Output is correct
27 Correct 250 ms 16984 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 12 ms 1604 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 184 ms 12484 KB Output is correct
32 Correct 179 ms 17808 KB Output is correct
33 Correct 149 ms 17844 KB Output is correct
34 Correct 208 ms 14548 KB Output is correct
35 Correct 185 ms 17868 KB Output is correct
36 Correct 149 ms 17980 KB Output is correct
37 Correct 256 ms 17864 KB Output is correct
38 Correct 117 ms 12432 KB Output is correct
39 Correct 103 ms 12580 KB Output is correct