답안 #378870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378870 2021-03-17T06:47:17 Z Mounir Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
1000 ms 274436 KB
#include <bits/stdc++.h>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;

map<char, int> conversion = {{'I', 0}, {'J', 1}, {'O', 2}};

signed main(){	
	int nLigs, nCols; cin >> nLigs >> nCols;
	int vals[nLigs][nCols];
	int occsLig[nLigs][nCols][3], occsCol[nLigs][nCols][3];

	for (int ilig  = 0; ilig < nLigs; ++ilig){
		for (int icol = 0; icol < nCols; ++icol){
			char cara; cin >> cara;
			vals[ilig][icol] = conversion[cara];
		}
	}

	for (int icol = 0; icol < nCols; ++icol){
		for (int color = 0; color < 3; ++color)
			occsLig[nLigs - 1][icol][color] = 0;
		occsLig[nLigs - 1][icol][vals[nLigs - 1][icol]]++;
		for (int ind = nLigs - 2; ind >= 0; --ind){
			for (int color = 0; color < 3; ++color)
				occsLig[ind][icol][color] = occsLig[ind + 1][icol][color];
			occsLig[ind][icol][vals[ind][icol]]++;
		}
	}

	for (int ilig = 0; ilig < nLigs; ++ilig){
		for (int color = 0; color < 3; ++color)
			occsCol[ilig][nCols - 1][color] = 0;
		occsCol[ilig][nCols - 1][vals[ilig][nCols - 1]]++;
		for (int ind = nCols - 2; ind >= 0; --ind){
			for (int color = 0; color < 3; ++color)
				occsCol[ilig][ind][color] = occsCol[ilig][ind + 1][color];
			occsCol[ilig][ind][vals[ilig][ind]]++;
		}
	}

	int sum = 0;
	for (int x = 0; x < nLigs; ++x)
		for (int y = 0; y < nCols; ++y){
			if (vals[x][y] == 1)
				sum += occsCol[x][y][2] * occsLig[x][y][0];
		}
	cout << sum << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 748 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 1 ms 760 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 748 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 1 ms 760 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 24 ms 10988 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 15 ms 7532 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 31 ms 14208 KB Output is correct
19 Correct 28 ms 13676 KB Output is correct
20 Correct 27 ms 13932 KB Output is correct
21 Correct 31 ms 14316 KB Output is correct
22 Correct 27 ms 13676 KB Output is correct
23 Correct 28 ms 13932 KB Output is correct
24 Correct 31 ms 14188 KB Output is correct
25 Correct 29 ms 13676 KB Output is correct
26 Correct 28 ms 13932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 1004 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 748 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 1 ms 760 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 24 ms 10988 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 15 ms 7532 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 31 ms 14208 KB Output is correct
19 Correct 28 ms 13676 KB Output is correct
20 Correct 27 ms 13932 KB Output is correct
21 Correct 31 ms 14316 KB Output is correct
22 Correct 27 ms 13676 KB Output is correct
23 Correct 28 ms 13932 KB Output is correct
24 Correct 31 ms 14188 KB Output is correct
25 Correct 29 ms 13676 KB Output is correct
26 Correct 28 ms 13932 KB Output is correct
27 Execution timed out 1016 ms 274436 KB Time limit exceeded
28 Halted 0 ms 0 KB -