답안 #754670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754670 2023-06-08T10:17:30 Z KN200711 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
338 ms 88420 KB
# include <bits/stdc++.h>
# define ll long long
using namespace std;

char arr[3002][3002];
int O[3002][3002], I[3002][3002];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, M;
	cin>>N>>M;
	for(int i=1;i<=N;i++) {
		for(int k=1;k<=M;k++) {
			cin>>arr[i][k];
		}
	}
	for(int i=1;i<=N;i++) {
		for(int k=M;k>=1;k--) {
			O[i][k] = O[i][k + 1];
			if(arr[i][k] == 'O') O[i][k]++;
		}
	}
	
	for(int i=1;i<=M;i++) {
		for(int k=N;k>=1;k--) {
			I[k][i] = I[k+1][i];
			if(arr[k][i] == 'I') I[k][i]++;
		}
	}
	
	ll ans = 0ll;
	for(int i=1;i<=N;i++) {
		for(int k=1;k<=M;k++) {
			if(arr[i][k] != 'J') continue;
			ans += 1ll * O[i][k] * 1ll * I[i][k];
		//	cout<<i<<" "<<k<<" "<<O[i][k]<<" "<<I[i][k]<<endl;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 2 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 2 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 6 ms 4308 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 7968 KB Output is correct
19 Correct 9 ms 7884 KB Output is correct
20 Correct 9 ms 7880 KB Output is correct
21 Correct 11 ms 7984 KB Output is correct
22 Correct 9 ms 7920 KB Output is correct
23 Correct 9 ms 7764 KB Output is correct
24 Correct 10 ms 8016 KB Output is correct
25 Correct 8 ms 7892 KB Output is correct
26 Correct 8 ms 7764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 2 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 6 ms 4308 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 7968 KB Output is correct
19 Correct 9 ms 7884 KB Output is correct
20 Correct 9 ms 7880 KB Output is correct
21 Correct 11 ms 7984 KB Output is correct
22 Correct 9 ms 7920 KB Output is correct
23 Correct 9 ms 7764 KB Output is correct
24 Correct 10 ms 8016 KB Output is correct
25 Correct 8 ms 7892 KB Output is correct
26 Correct 8 ms 7764 KB Output is correct
27 Correct 327 ms 87884 KB Output is correct
28 Correct 13 ms 25940 KB Output is correct
29 Correct 14 ms 7764 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 260 ms 72516 KB Output is correct
32 Correct 288 ms 88348 KB Output is correct
33 Correct 290 ms 88096 KB Output is correct
34 Correct 305 ms 84124 KB Output is correct
35 Correct 280 ms 88360 KB Output is correct
36 Correct 287 ms 88124 KB Output is correct
37 Correct 338 ms 88420 KB Output is correct
38 Correct 241 ms 72352 KB Output is correct
39 Correct 202 ms 72284 KB Output is correct