답안 #147204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147204 2019-08-28T12:05:32 Z joulej Bitaro the Brave (JOI19_ho_t1) C++17
0 / 100
2 ms 504 KB
#include <iostream>
#include <string>

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 < W; ++i)
	{
		for(int j = 0; j < H; ++j)
		{
			if(table[i][j] == 'J')
				answ += row[i][j] * 1LL * 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 Incorrect 2 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 2 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 2 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -