답안 #626068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626068 2022-08-11T07:44:58 Z l_reho Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
145 ms 18968 KB
#include <bits/stdc++.h>
using namespace std;

int H, W;
vector<string> V;

void solve(){
	cin>>H>>W;
	V.assign(H, "");
	
	for(int i = 0; i < H; i++) cin>>V[i];
	
	long long ans = 0;
	
	vector<int> orbInRow(H, 0), ingotInCol(W, 0);
	
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++) orbInRow[i] += V[i][j] == 'O';
	
	for(int i = 0; i < W; i++)
		for(int j = 0; j < H; j++) ingotInCol[i] += V[j][i] == 'I';
	
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(V[i][j] == 'O') orbInRow[i]--;
			if(V[i][j] == 'I') ingotInCol[j]--;	
			if(V[i][j] != 'J') continue;
			// mi servono gli ingot sotto i
			ans += (long long)orbInRow[i] * (long long)ingotInCol[j];
			
			// cout<<"DEBUG-->"<<i+1<<" "<<j+1<<" "<<orbInRow[i] * ingotInCol[j]<<endl;
			
		}
	}
	
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	solve();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 568 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 4 ms 816 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 4 ms 816 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 2 ms 716 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 2 ms 812 KB Output is correct
26 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 568 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 4 ms 816 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 4 ms 816 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 2 ms 716 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 2 ms 812 KB Output is correct
26 Correct 2 ms 724 KB Output is correct
27 Correct 145 ms 17824 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 6 ms 1620 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 84 ms 13160 KB Output is correct
32 Correct 106 ms 18800 KB Output is correct
33 Correct 108 ms 18780 KB Output is correct
34 Correct 105 ms 15224 KB Output is correct
35 Correct 104 ms 18800 KB Output is correct
36 Correct 100 ms 18968 KB Output is correct
37 Correct 139 ms 18960 KB Output is correct
38 Correct 59 ms 13036 KB Output is correct
39 Correct 52 ms 13244 KB Output is correct