Submission #147209

# Submission time Handle Problem Language Result Execution time Memory
147209 2019-08-28T12:18:21 Z joulej Bitaro the Brave (JOI19_ho_t1) C++17
Compilation error
0 ms 0 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];

			assert(cur[j] == 'I' || cur[j] == 'O' || cur[j] == '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;
}

Compilation message

joi2019_ho_t1.cpp: In function 'void solve()':
joi2019_ho_t1.cpp:37:4: error: 'assert' was not declared in this scope
    assert(cur[j] == 'I' || cur[j] == 'O' || cur[j] == 'J');
    ^~~~~~
joi2019_ho_t1.cpp:37:4: note: suggested alternative: 'qsort'
    assert(cur[j] == 'I' || cur[j] == 'O' || cur[j] == 'J');
    ^~~~~~
    qsort