답안 #378877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378877 2021-03-17T06:54:00 Z Mounir Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
630 ms 220524 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 bas[nLigs][nCols], droite[nLigs][nCols];

	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){
		bas[nLigs - 1][icol] = (vals[nLigs - 1][icol] == 0);
		for (int ind = nLigs - 2; ind >= 0; --ind)
			bas[ind][icol] = bas[ind + 1][icol] + (vals[ind][icol] == 0);
	}

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

	int sum = 0;
	for (int x = 0; x < nLigs; ++x)
		for (int y = 0; y < nCols; ++y){
			if (vals[x][y] == 1)
				sum += droite[x][y] * bas[x][y];
		}
	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 0 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 492 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 492 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 492 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 0 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 492 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 492 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 492 KB Output is correct
14 Correct 10 ms 4844 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 5 ms 3308 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 13 ms 6252 KB Output is correct
19 Correct 12 ms 5996 KB Output is correct
20 Correct 9 ms 6124 KB Output is correct
21 Correct 13 ms 6252 KB Output is correct
22 Correct 10 ms 5996 KB Output is correct
23 Correct 9 ms 6124 KB Output is correct
24 Correct 13 ms 6252 KB Output is correct
25 Correct 10 ms 6124 KB Output is correct
26 Correct 9 ms 6124 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 0 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 492 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 492 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 492 KB Output is correct
14 Correct 10 ms 4844 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 5 ms 3308 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 13 ms 6252 KB Output is correct
19 Correct 12 ms 5996 KB Output is correct
20 Correct 9 ms 6124 KB Output is correct
21 Correct 13 ms 6252 KB Output is correct
22 Correct 10 ms 5996 KB Output is correct
23 Correct 9 ms 6124 KB Output is correct
24 Correct 13 ms 6252 KB Output is correct
25 Correct 10 ms 6124 KB Output is correct
26 Correct 9 ms 6124 KB Output is correct
27 Correct 622 ms 208320 KB Output is correct
28 Correct 2 ms 1004 KB Output is correct
29 Correct 24 ms 16108 KB Output is correct
30 Correct 2 ms 876 KB Output is correct
31 Correct 448 ms 153196 KB Output is correct
32 Correct 564 ms 218988 KB Output is correct
33 Correct 529 ms 219756 KB Output is correct
34 Correct 524 ms 177772 KB Output is correct
35 Correct 566 ms 219116 KB Output is correct
36 Correct 497 ms 219756 KB Output is correct
37 Correct 630 ms 220524 KB Output is correct
38 Correct 381 ms 152044 KB Output is correct
39 Correct 371 ms 152556 KB Output is correct