답안 #689627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689627 2023-01-29T02:40:16 Z Warinchai Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
337 ms 121516 KB
#include<bits/stdc++.h>
using namespace std;
int sumi[3005][3005];
int sumo[3005][3005];
int main(){
	int h,w;
	cin>>h>>w;
	string ar[h+5];
	queue<pair<int,int> >q;
	for(int i=0;i<h;i++){
		cin>>ar[i];
		for(int j=0;j<w;j++){
			if(ar[i][j]=='J'){
				q.push({i,j});
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(ar[i][j]=='O'){
				sumo[i][j]++;
			}else if(ar[i][j]=='I'){
				sumi[i][j]++;
			}
			if(i!=0){
				sumi[i][j]+=sumi[i-1][j];
			}
			if(j!=0){
				sumo[i][j]+=sumo[i][j-1];
			}
		}
	}
	long long ans=0;
	while(!q.empty()){
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		int nx=0,ny=0;
		if(x==0){
			nx=sumi[h-1][y];
		}else{
			nx=sumi[h-1][y]-sumi[x-1][y];
		}
		if(y==0){
			ny=sumo[x][w-1];
		}else{
			ny=sumo[x][w-1]-sumo[x][y-1];
		}
		ans+=nx*ny;
	}
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1084 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1080 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1084 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1080 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 9 ms 6716 KB Output is correct
15 Correct 2 ms 3716 KB Output is correct
16 Correct 5 ms 4052 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 12 ms 7636 KB Output is correct
19 Correct 8 ms 6756 KB Output is correct
20 Correct 10 ms 7508 KB Output is correct
21 Correct 12 ms 7612 KB Output is correct
22 Correct 9 ms 7356 KB Output is correct
23 Correct 10 ms 7432 KB Output is correct
24 Correct 12 ms 7788 KB Output is correct
25 Correct 9 ms 6776 KB Output is correct
26 Correct 10 ms 7524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1084 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1080 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 9 ms 6716 KB Output is correct
15 Correct 2 ms 3716 KB Output is correct
16 Correct 5 ms 4052 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 12 ms 7636 KB Output is correct
19 Correct 8 ms 6756 KB Output is correct
20 Correct 10 ms 7508 KB Output is correct
21 Correct 12 ms 7612 KB Output is correct
22 Correct 9 ms 7356 KB Output is correct
23 Correct 10 ms 7432 KB Output is correct
24 Correct 12 ms 7788 KB Output is correct
25 Correct 9 ms 6776 KB Output is correct
26 Correct 10 ms 7524 KB Output is correct
27 Correct 315 ms 114604 KB Output is correct
28 Correct 10 ms 19268 KB Output is correct
29 Correct 22 ms 9824 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 241 ms 92532 KB Output is correct
32 Correct 239 ms 98816 KB Output is correct
33 Correct 255 ms 116244 KB Output is correct
34 Correct 269 ms 107136 KB Output is correct
35 Correct 257 ms 115776 KB Output is correct
36 Correct 264 ms 116136 KB Output is correct
37 Correct 337 ms 121516 KB Output is correct
38 Correct 176 ms 80428 KB Output is correct
39 Correct 185 ms 92236 KB Output is correct