답안 #818833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
818833 2023-08-10T06:54:50 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
20 / 100
6 ms 3796 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 305;

int main(){
	int h, w;
	ll sum = 0;
	ll zerocount, onecount;
	vector<string> grid;
	string input;
	ll pref0[N][N], pref1[N][N];
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> input;
		grid.push_back(input);
	}
	for(int i = 0; i < N-2; i++){
		for(int j = 0; j < N-2; j++){
			pref1[i][j] = 0;
			pref0[i][j] = 0;
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(grid[i][j] == 'O'){
				pref0[i][j]++;
			}
			else if(grid[i][j] == 'I'){
				pref1[i][j]++;
			}
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 1; j < w; j++){
			pref0[i][j] += pref0[i][j-1];
		}
	}
	for(int i = 1; i < h; i++){
		for(int j = 0; j < w; j++){
			pref1[i][j] += pref1[i-1][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(grid[i][j] == 'J'){
				// cout << i << " " << j << endl;
				zerocount = pref0[i][w-1] - pref0[i][j];
				onecount = pref1[h-1][j] - pref1[i][j];
				sum += zerocount*onecount;
			}
		}
	}
	cout << sum << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1632 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 1 ms 1748 KB Output is correct
8 Correct 1 ms 1748 KB Output is correct
9 Correct 1 ms 1748 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 1 ms 1748 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1632 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 1 ms 1748 KB Output is correct
8 Correct 1 ms 1748 KB Output is correct
9 Correct 1 ms 1748 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 1 ms 1748 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Runtime error 6 ms 3796 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1632 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 1 ms 1748 KB Output is correct
7 Correct 1 ms 1748 KB Output is correct
8 Correct 1 ms 1748 KB Output is correct
9 Correct 1 ms 1748 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 1 ms 1748 KB Output is correct
13 Correct 1 ms 1748 KB Output is correct
14 Runtime error 6 ms 3796 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -