답안 #147211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147211 2019-08-28T12:19:46 Z joulej Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
488 ms 88700 KB
#include <iostream>
#include <string>
#include <cassert>

using std::cin;
using std::cout;
using std::string;

using int64 = long long int;

const int MAX_N = 3007;

char table[MAX_N][MAX_N];
int row[MAX_N][MAX_N], col[MAX_N][MAX_N];
int H, W;
int64 answ = 0;

void fast_io()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

void solve()
{
	cin >> H >> W;

	for(int i = 0; i < H; ++i)
	{
		string cur;
		cin >> cur;

		for(int j = 0; j < W; ++j)
			table[i][j] = cur[j];
	}

	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
			row[i][j] = (table[i][j] == 'O');

		for(int j = W - 2; j >= 0; --j)
			row[i][j] += row[i][j + 1];
	}

	for(int j = 0; j < W; ++j)
	{
		for(int i = 0; i < H; ++i)
			col[i][j] = (table[i][j] == 'I');

		for(int i = H - 2; i >= 0; --i)
			col[i][j] += col[i + 1][j];
	}

	for(int i = 0; i < H; ++i)
	{
		for(int j = 0; j < W; ++j)
		{
			if(table[i][j] == 'J')
				answ += ((int64)row[i][j]) * ((int64)col[i][j]);
		}		
	}

	cout << answ << "\n";
}

int main()
{
	fast_io();
	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1580 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1448 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 1404 KB Output is correct
11 Correct 3 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1580 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1448 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 1404 KB Output is correct
11 Correct 3 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 11 ms 7544 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 7 ms 4344 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 12 ms 8080 KB Output is correct
19 Correct 11 ms 7928 KB Output is correct
20 Correct 11 ms 7928 KB Output is correct
21 Correct 12 ms 8052 KB Output is correct
22 Correct 11 ms 8056 KB Output is correct
23 Correct 11 ms 7928 KB Output is correct
24 Correct 13 ms 8056 KB Output is correct
25 Correct 12 ms 7928 KB Output is correct
26 Correct 12 ms 7928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1580 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1448 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 1404 KB Output is correct
11 Correct 3 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 11 ms 7544 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 7 ms 4344 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 12 ms 8080 KB Output is correct
19 Correct 11 ms 7928 KB Output is correct
20 Correct 11 ms 7928 KB Output is correct
21 Correct 12 ms 8052 KB Output is correct
22 Correct 11 ms 8056 KB Output is correct
23 Correct 11 ms 7928 KB Output is correct
24 Correct 13 ms 8056 KB Output is correct
25 Correct 12 ms 7928 KB Output is correct
26 Correct 12 ms 7928 KB Output is correct
27 Correct 463 ms 88320 KB Output is correct
28 Correct 23 ms 26104 KB Output is correct
29 Correct 15 ms 7800 KB Output is correct
30 Correct 3 ms 632 KB Output is correct
31 Correct 342 ms 72732 KB Output is correct
32 Correct 460 ms 88604 KB Output is correct
33 Correct 444 ms 88312 KB Output is correct
34 Correct 401 ms 84284 KB Output is correct
35 Correct 449 ms 88700 KB Output is correct
36 Correct 444 ms 88408 KB Output is correct
37 Correct 488 ms 88616 KB Output is correct
38 Correct 309 ms 72824 KB Output is correct
39 Correct 303 ms 72312 KB Output is correct