Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE PYTHON, JAVA OR C++ Problem Description A new and upcoming artist has a unique way to create checkered patterns. The idea is to

PLEASE USE PYTHON, JAVA OR C++

Problem Description

A new and upcoming artist has a unique way to create checkered patterns. The idea is to use an M-by-N canvas which is initially entirely black. Then the artist repeatedly chooses a row or column and runs their magic brush along the row or column. The brush changes the colour of each cell in the row or column from black to gold or gold to black.

Given the artists choices, your job is to determine how much gold appears in the pattern determined by these choices.

Input Specification

The first line of input will be a positive integer M. The second line of input will be a positive integer N. The third line of input will be a positive integer K. The remaining input will be K lines giving the choices made by the artist. Each of these lines will either be R followed by a single space and then an integer which is a row number, or C followed by a single space and then an integer which is a column number. Rows are numbered top down from 1 to M. Columns are numbered left to right from 1 to N.

The following table shows how the available 15 marks are distributed.

1 mark 4 marks 5 marks 5 marks

M = 1

M = 1 M 100

N = 1 N 100 N 100

K 100 K 100 K 100 K 1000000

only one cell, and up to 100 choices by the artist

only one row, and up to 100 choices by the artist

up to 100 rows, up to 100 columns, and up to 100 choices by the artist

up to 5 000 000 cells, and up to 1 000 000 choices by the artist

MN 5000000

Output Specification

Output one non-negative integer which is equal to the number of cells that are gold in the pattern determined by the artists choices.

Sample Input 1

3 3 2 R1 C1

Output for Sample Input 1

4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago