답안 #378871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378871 2021-03-17T06:49:04 Z Mounir Bitaro the Brave (JOI19_ho_t1) C++14
20 / 100
16 ms 7148 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()
using namespace std;

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

signed main(){	
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	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 512 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 12 ms 5612 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 9 ms 3840 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 16 ms 7148 KB Output is correct
19 Correct 13 ms 7020 KB Output is correct
20 Incorrect 12 ms 7020 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 12 ms 5612 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 9 ms 3840 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 16 ms 7148 KB Output is correct
19 Correct 13 ms 7020 KB Output is correct
20 Incorrect 12 ms 7020 KB Output isn't correct
21 Halted 0 ms 0 KB -