답안 #913551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
913551 2024-01-20T08:20:22 Z Pqrsaw Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
252 ms 150936 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast", "unroll-loops")
#define int long long 
const int maxn = 3e3 + 10, block = 320, mod = 1e9 + 7, inf = 2e9 + 10, lg = 22;
int n, m, o[maxn][maxn], ii[maxn][maxn], ans = 0;
char a[maxn][maxn];
void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
			if(a[i][j] == 'I'){
				ii[i][j]++;
			}
			else if(a[i][j] == 'O'){
				o[i][j]++;
			}
		}
	}
	for(int i = n; i >= 1; i--){
		for(int j = m; j >= 1; j--){
			ii[i][j] += ii[i + 1][j];
		}
	}
	for(int i = n; i >= 1; i--){
		for(int j = m; j >= 1; j--){
			o[i][j] += o[i][j + 1];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(a[i][j] == 'J'){
				ans += ii[i + 1][j] * o[i][j + 1];
			}
		}
	}
	cout << ans << "\n";
}
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T;
	while(T--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4600 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 3 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 3 ms 10844 KB Output is correct
8 Correct 4 ms 10996 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 3 ms 10844 KB Output is correct
11 Correct 3 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4600 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 3 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 3 ms 10844 KB Output is correct
8 Correct 4 ms 10996 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 3 ms 10844 KB Output is correct
11 Correct 3 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 11 ms 29276 KB Output is correct
15 Correct 5 ms 23704 KB Output is correct
16 Correct 6 ms 19032 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 14 ms 29276 KB Output is correct
19 Correct 10 ms 29436 KB Output is correct
20 Correct 9 ms 24924 KB Output is correct
21 Correct 13 ms 29276 KB Output is correct
22 Correct 8 ms 29276 KB Output is correct
23 Correct 10 ms 24920 KB Output is correct
24 Correct 14 ms 29272 KB Output is correct
25 Correct 8 ms 29276 KB Output is correct
26 Correct 10 ms 24924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4600 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 3 ms 10844 KB Output is correct
6 Correct 2 ms 10844 KB Output is correct
7 Correct 3 ms 10844 KB Output is correct
8 Correct 4 ms 10996 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 3 ms 10844 KB Output is correct
11 Correct 3 ms 10844 KB Output is correct
12 Correct 2 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 11 ms 29276 KB Output is correct
15 Correct 5 ms 23704 KB Output is correct
16 Correct 6 ms 19032 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 14 ms 29276 KB Output is correct
19 Correct 10 ms 29436 KB Output is correct
20 Correct 9 ms 24924 KB Output is correct
21 Correct 13 ms 29276 KB Output is correct
22 Correct 8 ms 29276 KB Output is correct
23 Correct 10 ms 24920 KB Output is correct
24 Correct 14 ms 29272 KB Output is correct
25 Correct 8 ms 29276 KB Output is correct
26 Correct 10 ms 24924 KB Output is correct
27 Correct 252 ms 150876 KB Output is correct
28 Correct 18 ms 94196 KB Output is correct
29 Correct 11 ms 19036 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 192 ms 129660 KB Output is correct
32 Correct 182 ms 150844 KB Output is correct
33 Correct 181 ms 150692 KB Output is correct
34 Correct 200 ms 150352 KB Output is correct
35 Correct 194 ms 150928 KB Output is correct
36 Correct 144 ms 150924 KB Output is correct
37 Correct 247 ms 150936 KB Output is correct
38 Correct 110 ms 129864 KB Output is correct
39 Correct 114 ms 129208 KB Output is correct