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



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

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

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

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

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

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

Homework 3 Solutions

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

Finite Field Problems: Solutions

2 Composition. Invertible Mappings

C.S. 430 Assignment 6, Sample Solutions

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Section 8.3 Trigonometric Equations

EE512: Error Control Coding

Other Test Constructions: Likelihood Ratio & Bayes Tests

Matrices and Determinants

The challenges of non-stable predicates

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

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)

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

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

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

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

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

ST5224: Advanced Statistical Theory II

Section 7.6 Double and Half Angle Formulas

PARTIAL NOTES for 6.1 Trigonometric Identities

Areas and Lengths in Polar Coordinates

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

The Simply Typed Lambda Calculus

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

FSM Toolkit Exercises

Lecture 13 - Root Space Decomposition II

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

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Example Sheet 3 Solutions

Reminders: linear functions

Fractional Colorings and Zykov Products of graphs

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

Areas and Lengths in Polar Coordinates

Every set of first-order formulas is equivalent to an independent set

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

On a four-dimensional hyperbolic manifold with finite volume

derivation of the Laplacian from rectangular to spherical coordinates

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

HY380 Αλγόριθμοι και πολυπλοκότητα Hard Problems

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

UNIVERSITY OF CAMBRIDGE INTERNATIONAL EXAMINATIONS International General Certificate of Secondary Education

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

Instruction Execution Times

Numerical Analysis FMN011

Homework 8 Model Solution Section

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

(C) 2010 Pearson Education, Inc. All rights reserved.

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Block Ciphers Modes. Ramki Thurimella

Ππόβλημα 1: Ανηιζηποθή 2 (Μονάδερ: 20)

* * GREEK 0543/02 Paper 2 Reading and Directed Writing May/June 2009

Trigonometric Formula Sheet

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

A Note on Intuitionistic Fuzzy. Equivalence Relation

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

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

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

5.4 The Poisson Distribution.

2. Let H 1 and H 2 be Hilbert spaces and let T : H 1 H 2 be a bounded linear operator. Prove that [T (H 1 )] = N (T ). (6p)

14 Lesson 2: The Omega Verb - Present Tense

Second Order Partial Differential Equations

Οι αδελφοί Montgolfier: Ψηφιακή αφήγηση The Montgolfier Βrothers Digital Story (προτείνεται να διδαχθεί στο Unit 4, Lesson 3, Αγγλικά Στ Δημοτικού)

Strukturalna poprawność argumentu.

Στο εργαστήριο θα μελετηθούν: Διδάσκων: Γιώργος Χατζηπολλάς. Εργαστήριο 2: Εργαλεία Συστήματος UNIX. Ομάδες για παρουσίαση

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

Advanced Subsidiary Unit 1: Understanding and Written Response

Math 6 SL Probability Distributions Practice Test Mark Scheme

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

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

[1] P Q. Fig. 3.1

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

1) Formulation of the Problem as a Linear Programming Model

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

Section 9.2 Polar Equations and Graphs

Section 8.2 Graphs of Polar Equations

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Statistical Inference I Locally most powerful tests

CRASH COURSE IN PRECALCULUS

Congruence Classes of Invertible Matrices of Order 3 over F 2

Assalamu `alaikum wr. wb.

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

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

Srednicki Chapter 55

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

Second Order RLC Filters

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

TMA4115 Matematikk 3

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

Inverse trigonometric functions & General Solution of Trigonometric Equations

Transcript:

Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Ολοι οι αριθμοί που αναφέρονται σε όλα τα ερωτήματα είναι μικρότεροι το 1000 εκτός αν ορίζεται διαφορετικά στη διατύπωση του προβλήματος. Διάρκεια: 3,5 ώρες Καλή επιτυχία! Πρόβλημα 1 Κύβοι 20 μονάδες Στην επιφάνεια ενός τραπεζιού υπάρχουν N κύβοι, όπου 1 N 100. Μια σειρά από εντολές μετακινεί τους κύβους. Κάθε εντολή αποτελείται από δύο ακέραιους αριθμούς, A και B, και προσδιορίζει ότι ο κύβος A μετακινείται πάνω στον κύβο B. Για παράδειγμα, η εντολή 1 3 υποδεικνύει ότι ο κύβος 1 μετακινείται πάνω στον κύβο 3. Η επιφάνεια του τραπεζιού υποδεικνύεται με τον αριθμό 0. Κατά συνέπεια, η εντολή 7 0 υποδεικνύει ότι ο κύβος 7 πρέπει να μετακινηθεί στην επιφάνεια του τραπεζιού. Αν ο κύβος A έχει μια στοίβα από κύβους πάνω του, τότε η στοίβα παραμένει πάνω στον A και μετακινείται μαζί με τον A. Αν ο κύβος B έχει μια στοίβα από κύβους πάνω του τότε εκείνη η στοίβα μετακινείται πάνω στην επιφάνεια του τραπεζιού ως έχει, ώστε να μην υπάρχει κύβος πάνω στον B, και μόνο τότε ο A (με οποιουσδήποτε κύβους πάνω του) μετακινείται στο B. Δεδομένα Εισόδου Η πρώτη γραμμή του αρχείου εισόδου είναι ένας ακέραιος αριθμός που υποδεικνύει τον αριθμό των κύβων που βρίσκονται πάνω στην επιφάνεια του τραπεζιού. Κάθε γραμμή που ακολουθεί είναι μια εντολή. Κάθε εντολή αποτελείται από δύο ακέραιους αριθμούς (A και B) χωρισμένους με ένα κενό διάστημα. 0 A N και 0 B N Η τελευταία γραμμή του αρχείου εισόδου είναι η εντολή 0 0, για την οποία καμιά ενέργεια δεν πρέπει να γίνει. Θεωρείστε ότι δεν θα υπάρχουν μη έγκυρες εντολές στο αρχείο εισόδου. Για παράδειγμα, η εντολή 0 3 είναι μη έγκυρη και δεν θα υπάρχει ποτέ στο αρχείο εισόδου. Δεδομένα εξόδου Η έξοδος του προγράμματος σας πρέπει να είναι η τελική κατάσταση των κύβων όταν όλες οι εντολές θα έχουν διεκπεραιωθεί. Το πρόγραμμα θα πρέπει να τυπώνει N γραμμές στο αρχείο εξόδου. Η πρώτη γραμμή θα πρέπει να δείχνει τη στοίβα των κύβων πάνω από τον κύβο 1. Η δεύτερη να δείχνει τη στοίβα των κύβων πάνω από τον κύβο 2. Η n-ιοστή γραμμή δείχνει τη στοίβα των κύβων πάνω από τον κύβο n. Κάθε γραμμή ξεκινά με την αρίθμηση του κύβου n ακολουθούμενη από μια άνω-κάτω τελεία. Αν υπάρχουν κύβοι πάνω από τον κύβο n τότε η άνω-κάτω τελεία ακολουθείται από ένα κενό διάστημα κι έπειτα την λίστα των κύβων που βρίσκονται πάνω από τον κύβο n.

Η λίστα με τους αριθμούς των κύβων που ακολουθούν την άνω-κάτω τελεία πρέπει να εμφανίζονται με την ίδια σειρά που είναι στοιβαγμένοι, ξεκινώντας με τον κύβο που βρίσκεται χαμηλότερα στη στοίβα. Problem 1 - Blocks There are N blocks on the surface of a table, where 1 N 100. A list of commands moves the blocks. Each command is composed of two integers, A and B, which indicates that block A is moved above block B. For example, the command 1 3 indicates that block 1 is moved above block 3. The surface of the table is denoted with the number 0. Therefore, the command 7 0 indicates that block 7 should be moved on to the surface of the table. If block A has a stack of blocks above it, then that stack remains above A and is moved together with block A. If block B has a stack of blocks above it then that stack is moved to the surface of the table as is, so that there are no blocks above B, and then A (with any blocks above it) is moved on top of B. Input The first line of the input file is an integer indicating the number of blocks that are on the surface of the table. Each of the following lines in the file is a command. Each command is composed of two integers (A and B) separated with a single space. 0 A N and 0 B N The last line of the input file has the command 0 0, where no action should be carried out. Assume no invalid commands will appear in the input file. For example the command 0 3 is invalid and would never appear in the input file. Output The output of your program should be the final state of the blocks after all the commands have been carried out. Your program should output N lines to the file. The first line indicates the stack of the blocks above block 1. The second line indicates the stack of blocks above block 2. The nth line indicates the stack of blocks above block n. Each line starts with the block number n followed by a colon. If there are any blocks above block n then the colon is followed by a space, and then a list of blocks above block n. The list of block numbers after the colon have to appear in the order in which they are stacked, beginning with the block that is the lowest in the stack. Example Παράδειγμα

5 3 1 5 3 3 4 2 3 3 0 4 2 0 0 1: 2: 4 3: 2 4 4: 5: Πρόβλημα 2 Μήλα 30 μονάδες

Δίνεται ένα σύνολο από N μήλα. Κάθε μήλο έχει κάποιο βάρος. Η πρώτη γραμμή του αρχείου εισόδου είναι ο ακέραιος αριθμός N, όπου 1 N 100. Οι ακόλουθες N γραμμές είναι τα βάρη των μήλων W i σε γραμμάρια, όπου 1 i N and 0 < W i 1000 και W i είναι ακέραιος αριθμός. Ζητείται να επιλεγούν κάποια από τα μήλα και να τοποθετηθούν σε ένα καλάθι με μέγιστη αντοχή 1000 γραμμάρια μήλων. Θέλουμε να μεγιστοποιήσουμε το βάρος των μήλων που επιλέξαμε. Γράψε πρόγραμμα το οποίο διαλέγει ένα υποσύνολο από μήλα όπου το βάρος τους είναι το μέγιστο δυνατό, άλλα όχι μεγαλύτερο από 1000 γραμμάρια. Το αρχείου εξόδου θα πρέπει να αποτελείται από το βάρος του κάθε μήλου που επιλέγηκε, ένα βάρος σε κάθε γραμμή, με οποιαδήποτε σειρά. Problem 2 - Apples You are given a set of N apples. Each apple has a weight. The first line of the file is the integer N, where 1 N 100. The following N lines are the weights of the apples W i in grams. 1 i N and 0 < W i 1000. Wi is an integer. The problem is to choose some of these apples and put them in a bag that can hold a maximum of 1000 grams of apples. We want the weight of the chosen apples to be the maximum possible. Write a program that picks a subset of apples whose total weight is the maximum possible, but not greater than 1000 grams. The output file should contain the weights of the apples picked by the program, one weight on each line, in any order. Examples - Παράδειγματα 5 200 300 200 400 200 300

4 900 450 300 450 Πρόβλημα 3 Μέγιστο Άθροισμα 50 μονάδες Δεδομένου ενός 2-διάστατου πίνακα από θετικούς και αρνητικούς ακέραιους αριθμούς, βρείτε το υποορθογώνιο με το μεγαλύτερο άθροισμα. Το άθροισμα ενός ορθογωνίου είναι το άθροισμα όλων των στοιχείων σε εκείνο το ορθογώνιο. Το υπο-ορθογώνιο με το μεγαλύτερο άθροισμα θα αναφέρεται ως το μέγιστο υπο-ορθογώνιο. Ένα υπο-ορθογώνιο είναι κάθε ενιαίο ορθογώνιο του πίνακα μέγέθους 1x1 ή μεγαλύτερο. Για παράδειγμα, το μέγιστο υπο-ορθογώνιο του πίνακα: βρίσκεται στην κάτω αριστερή γωνιά: και έχει άθροισμα στοιχείων 15. Αρχείου Εισόδου: Η είσοδος αποτελείται από ένα NxN πίνακα με ακέραιους αριθμούς, όπου 1 N 100. Η είσοδος ξεκινά με ένα και μοναδικό ακέραιο αριθμό N στην πρώτη γραμμή υποδεικνύοντας το μέγεθος του 2- διάστατου τετραγωνικού πίνακα. Η δεύτερη γραμμή του αρχείου εισόδου αποτελείται από N 2 ακέραιους αριθμούς χωρισμένους με κενά διαστήματα. Αυτοί οι N 2 ακέραιοι αριθμοί συνθέτουν τον πίνακα γραμμήπρος-γραμμή (δηλ. Όλοι οι αριθμοί στην πρώτη γραμμή, αριστερά-προς-δεξιά, έπειτα οι αριθμοί στη δεύτερη γραμμή, αριστερά-προς-δεξιά, κοκ). Οι αριθμοί του πίνακα θα είναι αριθμοί μεταξύ του -127 και του 127, συμπεριλαμβανομένου. Το αρχείο εξόδου πρέπει να αποτελείται από μια και μοναδική γραμμή που να περιέχει ένα και μοναδικό ακέραιο αριθμό που να δείχνει το άθροισμα του μέγιστου υπο-ορθογωνίου.

Problem 3 - Maximum Sum Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the largest sum. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the subrectangle with the largest sum is referred to as the maximal sub-rectangle. A sub-rectangle is any contiguous sub-array of size 1x1or greater located within the whole array. As an example, the maximal sub-rectangle of the array: is in the lower-left-hand corner: and has the sum of 15. The input consists of an NxN array of integers, where 1 N 100. The input begins with a single positive integer N on a line by itself indicating the size of the square two dimensional array. The second line of the input file has N 2 integers separated by spaces. These N 2 integers make up the array in rowmajor order (i.e. all numbers on the first row, left-to-right, then all numbers on the second row, left-toright, etc.). The numbers in the array will be in the range -127 to 127, inclusive. The input file is. The output file should consist of a single line with a single integer, which is the sum of the maximal sub-rectangle. Example1 Παράδειγμα 1 4 0-2 -7 0 9 2-6 2-4 1-4 1-1 8 0-2 15 Example 2 Παράδειγμα 2 2 40-2 1 1 41