Submission #702349

# Submission time Handle Problem Language Result Execution time Memory
702349 2023-02-23T15:58:02 Z Koful123 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
225 ms 83736 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
void solve(){
 	
 	int n,m;
 	cin >> n >> m;

 	vector<string> s(n);
 	for(int i = 0; i < n; i++){
 		cin >> s[i];
 	}

 	vector<vector<int>> cnt(n,vector<int>(m));
 	for(int j = 0; j < m; j++){
 		for(int i = n - 1; i >= 0; i--){
 			cnt[i][j] = (i + 1 < n ? cnt[i + 1][j] : 0) + (s[i][j] == 'I');
 		}
 	}

 	int ans = 0;
 	for(int i = 0; i < n; i++){
 		int freq = 0;
 		for(int j = m - 1; j >= 0; j--){
 			freq += (s[i][j] == 'O');
 			if(s[i][j] == 'J'){
 				ans += freq * cnt[i][j];
 			}
 		}
 	}

 	cout << ans << endl;
}
 
signed main(){ 
 
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int t = 1;
//	cin >> t;
 
	while(t--)
		solve();
 	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 0 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 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 4 ms 2128 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 4 ms 2760 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 3 ms 2764 KB Output is correct
21 Correct 4 ms 2772 KB Output is correct
22 Correct 3 ms 2644 KB Output is correct
23 Correct 3 ms 2772 KB Output is correct
24 Correct 5 ms 2764 KB Output is correct
25 Correct 3 ms 2660 KB Output is correct
26 Correct 3 ms 2732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 4 ms 2128 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 4 ms 2760 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 3 ms 2764 KB Output is correct
21 Correct 4 ms 2772 KB Output is correct
22 Correct 3 ms 2644 KB Output is correct
23 Correct 3 ms 2772 KB Output is correct
24 Correct 5 ms 2764 KB Output is correct
25 Correct 3 ms 2660 KB Output is correct
26 Correct 3 ms 2732 KB Output is correct
27 Correct 200 ms 79400 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 8 ms 6696 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 141 ms 59396 KB Output is correct
32 Correct 187 ms 83348 KB Output is correct
33 Correct 187 ms 83736 KB Output is correct
34 Correct 168 ms 68232 KB Output is correct
35 Correct 184 ms 83224 KB Output is correct
36 Correct 200 ms 83524 KB Output is correct
37 Correct 225 ms 83724 KB Output is correct
38 Correct 127 ms 58916 KB Output is correct
39 Correct 120 ms 58960 KB Output is correct