답안 #136778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136778 2019-07-26T08:45:37 Z SirCeness Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
461 ms 79808 KB
#include <bits/stdc++.h>

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define ppair(x) "(" << x.first << ", " << x.second << ")"
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

int n, m;
int dpo[3003][3003];
int dpi[3003][3003];
char mat[3003][3003];

int main(){
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> mat[i][j];
		}
	}

	for (int i = 0; i < n; i++){
		int sum = 0;
		for (int j = m-1; j >= 0; j--){
			sum += mat[i][j] == 'O';
			dpo[i][j] = sum;
		}
	}

	for (int j = 0; j < m; j++){
		int sum = 0;
		for (int i = n-1; i >= 0; i--){
			sum += mat[i][j] == 'I';
			dpi[i][j] = sum;
		}
	}

	/*for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cout << dpo[i][j];
		}
		cout << endl;
	}
	cout << endl;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cout << dpi[i][j];
		}
		cout << endl;
	}
	cout << endl;*/

	ll ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (mat[i][j] == 'J') ans += (ll)dpi[i][j]*(ll)dpo[i][j];
		}
	}

	cout << ans << endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1500 KB Output is correct
7 Correct 3 ms 1404 KB Output is correct
8 Correct 3 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 3 ms 1448 KB Output is correct
12 Correct 3 ms 1500 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1500 KB Output is correct
7 Correct 3 ms 1404 KB Output is correct
8 Correct 3 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 3 ms 1448 KB Output is correct
12 Correct 3 ms 1500 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 12 ms 7292 KB Output is correct
15 Correct 5 ms 4984 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 2 ms 476 KB Output is correct
18 Correct 14 ms 7772 KB Output is correct
19 Correct 12 ms 7676 KB Output is correct
20 Correct 13 ms 7600 KB Output is correct
21 Correct 15 ms 7732 KB Output is correct
22 Correct 13 ms 7672 KB Output is correct
23 Correct 13 ms 7688 KB Output is correct
24 Correct 14 ms 7804 KB Output is correct
25 Correct 13 ms 7644 KB Output is correct
26 Correct 13 ms 7580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1500 KB Output is correct
7 Correct 3 ms 1404 KB Output is correct
8 Correct 3 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 3 ms 1448 KB Output is correct
12 Correct 3 ms 1500 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 12 ms 7292 KB Output is correct
15 Correct 5 ms 4984 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 2 ms 476 KB Output is correct
18 Correct 14 ms 7772 KB Output is correct
19 Correct 12 ms 7676 KB Output is correct
20 Correct 13 ms 7600 KB Output is correct
21 Correct 15 ms 7732 KB Output is correct
22 Correct 13 ms 7672 KB Output is correct
23 Correct 13 ms 7688 KB Output is correct
24 Correct 14 ms 7804 KB Output is correct
25 Correct 13 ms 7644 KB Output is correct
26 Correct 13 ms 7580 KB Output is correct
27 Correct 430 ms 79732 KB Output is correct
28 Correct 23 ms 25972 KB Output is correct
29 Correct 22 ms 7252 KB Output is correct
30 Correct 3 ms 632 KB Output is correct
31 Correct 318 ms 66496 KB Output is correct
32 Correct 408 ms 79728 KB Output is correct
33 Correct 441 ms 79416 KB Output is correct
34 Correct 393 ms 77092 KB Output is correct
35 Correct 413 ms 79708 KB Output is correct
36 Correct 427 ms 79476 KB Output is correct
37 Correct 461 ms 79808 KB Output is correct
38 Correct 292 ms 66512 KB Output is correct
39 Correct 287 ms 66208 KB Output is correct