Submission #147208

# Submission time Handle Problem Language Result Execution time Memory
147208 2019-08-28T12:16:33 Z joulej Bitaro the Brave (JOI19_ho_t1) C++17
0 / 100
2 ms 376 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 += ((int64)row[i][j]) * ((int64)col[i][j]);
		}		
	}

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

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

	return 0;
}
# Verdict Execution time Memory 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 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 376 KB Output isn't correct
5 Halted 0 ms 0 KB -