Submission #378872

# Submission time Handle Problem Language Result Execution time Memory
378872 2021-03-17T06:49:32 Z Mounir Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
678 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 int long long
#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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 1 ms 876 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 876 KB Output is correct
8 Correct 1 ms 876 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 1 ms 876 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 876 KB Output is correct
8 Correct 1 ms 876 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 876 KB Output is correct
14 Correct 15 ms 10860 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 9 ms 7404 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 21 ms 14060 KB Output is correct
19 Correct 16 ms 13420 KB Output is correct
20 Correct 16 ms 13804 KB Output is correct
21 Correct 20 ms 14060 KB Output is correct
22 Correct 17 ms 13548 KB Output is correct
23 Correct 18 ms 13804 KB Output is correct
24 Correct 19 ms 14060 KB Output is correct
25 Correct 16 ms 13420 KB Output is correct
26 Correct 16 ms 13804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 1 ms 876 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 876 KB Output is correct
8 Correct 1 ms 876 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 876 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 876 KB Output is correct
14 Correct 15 ms 10860 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 9 ms 7404 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 21 ms 14060 KB Output is correct
19 Correct 16 ms 13420 KB Output is correct
20 Correct 16 ms 13804 KB Output is correct
21 Correct 20 ms 14060 KB Output is correct
22 Correct 17 ms 13548 KB Output is correct
23 Correct 18 ms 13804 KB Output is correct
24 Correct 19 ms 14060 KB Output is correct
25 Correct 16 ms 13420 KB Output is correct
26 Correct 16 ms 13804 KB Output is correct
27 Runtime error 678 ms 274436 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -