ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Σχετικά έγγραφα
ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

2 Composition. Invertible Mappings

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 11/3/2006

1. Πόσοι αριθμοί μικρότεροι του διαιρούνται με όλους τους μονοψήφιους αριθμούς;

Homework 3 Solutions

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 2008

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Section 8.3 Trigonometric Equations

Section 7.6 Double and Half Angle Formulas

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

C.S. 430 Assignment 6, Sample Solutions

Numerical Analysis FMN011

TMA4115 Matematikk 3

Approximation of distance between locations on earth given by latitude and longitude

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

The challenges of non-stable predicates

Math 6 SL Probability Distributions Practice Test Mark Scheme

EE512: Error Control Coding

Matrices and Determinants

Areas and Lengths in Polar Coordinates

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

Example Sheet 3 Solutions

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

( ) 2 and compare to M.

The Simply Typed Lambda Calculus

[1] P Q. Fig. 3.1

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Areas and Lengths in Polar Coordinates

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Homework 8 Model Solution Section

Section 9.2 Polar Equations and Graphs

CHAPTER 101 FOURIER SERIES FOR PERIODIC FUNCTIONS OF PERIOD

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Trigonometric Formula Sheet

Instruction Execution Times

the total number of electrons passing through the lamp.

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

derivation of the Laplacian from rectangular to spherical coordinates

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

FSM Toolkit Exercises

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. ΕΠΛ342: Βάσεις Δεδομένων. Χειμερινό Εξάμηνο Φροντιστήριο 10 ΛΥΣΕΙΣ. Επερωτήσεις SQL

Second Order RLC Filters

ΚΥΠΡΙΑΚΗ ΜΑΘΗΜΑΤΙΚΗ ΕΤΑΙΡΕΙΑ IΔ ΚΥΠΡΙΑΚΗ ΜΑΘΗΜΑΤΙΚΗ ΟΛΥΜΠΙΑΔΑ ΑΠΡΙΛΙΟΥ 2013 Β & Γ ΛΥΚΕΙΟΥ.

Solutions to Exercise Sheet 5

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

4.6 Autoregressive Moving Average Model ARMA(1,1)

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

On a four-dimensional hyperbolic manifold with finite volume

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Review Test 3. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Inverse trigonometric functions & General Solution of Trigonometric Equations

ST5224: Advanced Statistical Theory II

Modbus basic setup notes for IO-Link AL1xxx Master Block

PARTIAL NOTES for 6.1 Trigonometric Identities

UNIVERSITY OF CALIFORNIA. EECS 150 Fall ) You are implementing an 4:1 Multiplexer that has the following specifications:

Finite Field Problems: Solutions

Srednicki Chapter 55

How to register an account with the Hellenic Community of Sheffield.

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

Lecture 2. Soundness and completeness of propositional logic

1) Formulation of the Problem as a Linear Programming Model

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

Assalamu `alaikum wr. wb.

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Pg The perimeter is P = 3x The area of a triangle is. where b is the base, h is the height. In our case b = x, then the area is

Γ ΓΥΜΝΑΣΙΟΥ & Α ΛΥΚΕΙΟΥ

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

1. Ηλεκτρικό μαύρο κουτί: Αισθητήρας μετατόπισης με βάση τη χωρητικότητα

Second Order Partial Differential Equations

Section 8.2 Graphs of Polar Equations

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

Math221: HW# 1 solutions

2. Μηχανικό Μαύρο Κουτί: κύλινδρος με μια μπάλα μέσα σε αυτόν.

Fractional Colorings and Zykov Products of graphs

6.3 Forecasting ARMA processes

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

CRASH COURSE IN PRECALCULUS

Trigonometry 1.TRIGONOMETRIC RATIOS

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Volume of a Cuboid. Volume = length x breadth x height. V = l x b x h. The formula for the volume of a cuboid is

Strain gauge and rosettes

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

Solution Series 9. i=1 x i and i=1 x i.

Figure 3 Three observations (Vp, Vs and density isosurfaces) intersecting in the PLF space. Solutions exist at the two indicated points.

Transcript:

Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Αν κάπου κάνετε κάποιες υποθέσεις να αναφερθούν στη σχετική ερώτηση. Όλα τα αρχεία που αναφέρονται στα προβλήματα βρίσκονται στον ίδιο φάκελο με το εκτελέσιμο αρχείο του προγράμματός σας. Διάρκεια: ώρες Καλή επιτυχία! Πρόβλημα 1 (0 μονάδες) Σας δίνεται μία τριγωνική πυραμίδα αποτελούμενη από Ν (1<Ν 1000) επίπεδα η οποία περιέχει ακέραιους αριθμούς. Γράψτε ένα πρόγραμμα το οποίο να βρίσκει το μέγιστο άθροισμα αριθμών όταν ακολουθηθεί μια διαδρομή που ξεκινά από το κορυφαίο επίπεδο και τελειώνει στο πάτο της πυραμίδας. Σε κάθε βήμα μπορείτε να κινηθείτε διαγώνια κάτω είτε προς τα αριστερά είτε προς τα δεξιά, όπως δείχνουν οι γραμμές που ενώνουν τους αριθμούς στο πιο κάτω διάγραμμα. Είσοδος Η πρώτη γραμμή του αρχείου εισόδου περιέχει τον αριθμό Ν. Η πρώτη γραμμή του αρχείου περιέχει τον αριθμό Ν. Οι επόμενες Ν γραμμές περιέχουν ακέραιους για το αντίστοιχο επίπεδο, χωρισμένους με ένα κενό χαρακτήρα. Οι αριθμοί αυτοί είναι ακέραιοι θετικοί με μέγιστη τιμή το 100. Έξοδος Το αρχείο εξόδου πρέπει να περιέχει ένα μόνο αριθμό ο οποίος αντιστοιχεί στο μέγιστο άθροισμα που βρήκε το πρόγραμμα σας. Παράδειγμα 1 Αυτή η πυραμίδα έχει επίπεδα. Στο μέγιστο άθροισμα καταλήγουμε ξεκινώντας από το 8, κινούμενοι στο 12 και μετά στο 7. Το άθροισμα είναι 27. 8 12 1 2 7 8 27 1/7

Παράδειγμα 2 Αυτή η πυραμίδα έχει επίπεδα. Στο μέγιστο άθροισμα καταλήγουμε ακολουθώντας την διαδρομή από το, στο 2, στο 2 και τέλος στο 70. Το άθροισμα είναι 107. 11 2 1 2 2 81 5 70 9 107 Problem 1 (0 points) You are given a triangular pyramid of numbers with N (1<Ν 1000) levels. Write a program that finds the highest sum of numbers starting from the top level and ending at the bottom level of the pyramid. At each step you can go diagonally down to the left or diagonally down to the right as indicated by the lines joining the numbers in the diagrams below. Input The first line of the input file contains N. The following N lines contain the integers for each level, separated by a single space. These integers are positive and have a maximum value of 100. Output The output file should contain a single number, which is the maximum sum that the program has found. 2/7

Εxample 1 The pyramid has levels. The maximum sum is obtained by starting at 8, moving to 12, and then to 7. The sum is 27. 8 12 1 2 7 8 27 Εxample 2 The pyramid has levels. The maximum sum is obtained by following the path from, to 2, to 2, and then to 70. The sum is 107. 11 2 1 2 2 81 5 70 9 107 /7

Πρόβλημα 2 Σας δίνεται ένα διάγραμμα το οποίο είναι ένα τετραγωνικό πλέγμα με διαστάσεις NxN, όπου 1<Ν 100. Κάθε τετράγωνο μέσα στο πλέγμα είναι είτε μαύρο ή άσπρο. Δύο μαύρα τετράγωνα θα τα αποκαλούμε ενωμένα αν εφάπτονται στον οριζόντιο ή στον κάθετο άξονα (όχι στο διαγώνιο). Ορίζουμε σαν αντικείμενο ένα σύνολο από ένα ή περισσότερα μαύρα τετράγωνα τέτοια ώστε κάθε μαύρο τετράγωνο στο αντικείμενο να είναι ενωμένο με τουλάχιστον ένα άλλο μαύρο τετράγωνο του αντικειμένου. Μέρος A (0 μονάδες) Βρείτε πόσα αντικείμενα υπάρχουν στο διάγραμμα. Μέρος Β (0 μονάδες) Βρέστε ποια άσπρα τετράγωνα θα πρέπει να μετατραπούν σε μαύρα έτσι ώστε να υπάρχει μόνο ένα αντικείμενο στο διάγραμμα. Η λύση που θα μετατρέπει τον ελάχιστο αριθμό άσπρων τετραγώνων (βέλτιστη λύση) θα παίρνει όλες τις μονάδες. Οι λύσεις που θα μετατρέπουν μεγαλύτερο αριθμό άσπρων τετραγώνων από τη βέλτιστη λύση θα παίρνουν κι αυτές μονάδες, αλλά θα αφαιρούνται μονάδες για κάθε επιπλέον άσπρο κουτί που μετατρέπεται σε μαύρο. Συνεπώς, όσο περισσότερο αποκλίνει μια λύση από τη βέλτιστη, τόσο λιγότερες μονάδες θα παίρνει. Είσοδος Η πρώτη γραμμή του αρχείου εισόδου περιέχει τον αριθμό Ν. Σε κάθε μία από τις επόμενες Ν γραμμές, θα περιέχονται Ν αριθμοί. Οι αριθμοί αυτοί θα είναι είτε 0 είτε 1 και θα χωρίζονται με ένα κενό χαρακτήρα. Το 0 αντιπροσωπεύει ένα μαύρο τετράγωνο και το 1 ένα άσπρο τετράγωνο. Έξοδος Η πρώτη γραμμή του αρχείου εξόδου θα πρέπει να περιέχει ένα ακέραιο αριθμό, την απάντηση του Μέρους Α. Οι επόμενες Ν γραμμές θα πρέπει να δείχνουν το μετατρεμμένο διάγραμμα με παρόμοιο τρόπο όπως κατά την είσοδο (με 0 και 1). Αυτή τη φορά όμως, στη θέση των 1 που θα μετατραπούν θα πρέπει να τυπώνεται ο αριθμός 2. /7

Παράδειγμα Το διάγραμμα στα αριστερά δείχνει ότι υπάρχουν αντικείμενα. Το διάγραμμα στα δεξιά δείχνει ότι εάν τα τέσσερα λευκά τετράγωνα τα οποία έχουν σημαδευτεί γκρίζα, γίνουν μαύρα, τότε θα υπάρχει ένα μόνο αντικείμενο στο διάγραμμα. Αυτές οι τέσσερις μετατροπές αποτελούν τη βέλτιστη λύση. Δεδομένα εισόδου και αποτέλεσμα εξόδου (βέλτιστη λύση) παραδείγματος. 6 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 2 2 1 1 0 1 1 2 1 Μια πιθανή μη-βέλτιστη λύση του προβλήματος. 1 1 2 2 0 0 1 0 0 1 1 2 1 0 1 1 1 2 Η λύση αυτή θα έχανε 8% των μονάδων του προβλήματος. 5/7

Problem 2 You are given a diagram which is a square grid with dimensions NxN, where 1<N 100. Each square in the grid is either white or black. Two black squares are said to be connected if they are directly adjacent in the horizontal or vertical direction (not in the diagonal direction). We define an object as a set of one or more black squares such that each black square in the object is connected to at least one other black square in the object. Part A (0 points) Find how many objects there are in the given diagram. Part B (0 points) Determine which white squares need to be converted to black squares so that there will be only one object in the diagram. A solution which converts the least number of white squares (the optimal solution) will be awarded maximum points. Solutions which convert more squares than the optimal will still be awarded points, but will be penalized for each extra square converted to black. Consequently, the more a solution deviates from the optimal one the less points it will be awarded. Input The first line of the input file contains the number N. Each of the following N lines contains N numbers on each line. The numbers on each line are either a 0 or a 1, separated by a single space. A 0 represents a black square, and a 1 represents a white square. Output The first line of the output file should contain the answer to Part A. The next N lines show the grid using 0 s and 1 s as in the input file. However, the 1 s representing the white squares to be converted to black squares should be replaced with the number 2. 6/7

Εxample The diagram on the left shows that there are objects. The diagram on the right shows that if the four white squares marked grey were changed to black, then there would be one object in the diagram. These four changed squares form the optimal solution of this example. Input data and output results (optimal solution) for the example. 6 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 2 2 1 1 0 1 1 2 1 A non-optimal solution: 1 1 2 2 0 0 1 0 0 1 1 2 1 0 1 1 1 2 This solution would lose 8% of the points. 7/7