320SC科学计算

Computer Science 320SC

Programming Assignment 3Due: Friday Sept 1st or Friday Sept 8th (11:59pm)

1. Requirements

This assignment tests you understanding of how to apply network flow to a real-world application. Wehave taken a recent New Zealand Programming Contest question and repackaged it for your requirements.See the following two pages for specifications.

2. Submission

There will problem two sets of inputs Easy and Hard worth 3 and 2 marks, respectively, on the computerscience automarker https://www.automarker.cs.auckland.ac.nz/. It is expected that you will needa network flow solution for the harder test case.For this assignment you can use any language supported on theautomarker and can submit up to10 times for each problem before occuring a 20% penalty. Then a maximum of 20 times to preventoverloading of the server.Also, as a bonus, if you finish both parts of the assignment before the first deadline of Sept 1st, you willget 10% added to your Assignment 3 score (e.g. 5.5 marks), which willbe manually added to Canvas.You need to have solved both test sets to qualify.NZPC2023 MOLECULESOrganic molecules can be amazingly complex and need a great
variety of shapes and conventions to represent them,particularly if we wish to depict details of their 3-dimensionalstructures. For this problem, we will restrict ourselves toreasonably simple compounds with only single bonds betweenatoms, that can be represented on a simple rectangular gridwith bonds aligned horizontally or vertically. In such molecules,carbon is bonded to 4 adjacent atoms, nitrogen to 3, oxygen to2 and hydrogen to 1. These numbers are called the valences ofthe atoms.Of course, not all such grids represent valid molecules. Your task is to write aprogram that will determine whether a given grid could represent one or more validmolecules, satisfying the valences of all the atoms. Note that the molecule(s) in avalid grid do not need to exist in the real world.

3. Input

The first line of the input consists of a pair of integers (r and c, 1 ≤ r, c ≤ 20) representingthe number of rows and columns in the rectangle to follow. The next r lines contain ccharacters each, where the characters are chosen from the set {‘H’, ‘O’, ‘N’, ‘C’, ‘.’}representing hydrogen, oxygen, nitrogen, carbon and ‘empty’, respectively.OutputOutput consists of a single line containing a single word:Valid if it possible to draw horizontal and/or vertical bonds betweenneighbouring atoms so as to satisfy the valences of all the atoms inthe grid, orInvalid if no such set of bonds exists.

你可能感兴趣的:(算法)