German Collegiate Programming Contest

Similar documents
Cellular Biophysics SS Prof. Manfred Radmacher

LERNCOACHING IN SCHULE. lernen-lernen.eu Jeannine Hohmann

More Examples and Applications on AVL Tree

Aufklärung Nr. 27: Pneumokokken (Konjugat) Englisch / English

Aufklärung Nr. 9: Hepatitis A Englisch / English

Example 1. Students Mock exam Final exam. Bill Jane Jack Pat John Susan Anna Margret Peggy Joe William Ron Bob Sally Marry

Numerical Simulation of Laminar and Turbulent Nozzle-Jet Flows and Their Sound

AIC. Schweiz Suisse Svizzera Switzerland skyguide, swiss air navigation services ltd AIP services ch-8602 wangen bei dübendorf

Welche Bausteine und Vorgehensweisen gehören zur Methodologie des NLP?

CERTIFICATE OF CALIBRATION

Graph Algorithms Introduction to Data Structures. Ananda Gunawardena 8/2/2011 1

Outlier Analysis. Lijun Zhang

Chapter 3 Software Packages to Install How to Set Up Python Eclipse How to Set Up Eclipse... 42

The effect of the refusal avoidance training experiment on final disposition codes in the German ESS-2 Schnell, Rainer; Trappmann, Mark

Grade 6 Math Circles Winter February 6/7 Number Theory

Management of Metastatic Bone Pain: Preliminary Results with Single Fraction (4 Gy) Radiotherapy

12.INTERNATIONALER ATG-Cup 2017 Samstag, 22. April, 9.30 a.m.

SUSPECT ADVERSE REACTION REPORT

Grade 6 Math Circles Winter February 6/7 Number Theory - Solutions Warm-up! What is special about the following groups of numbers?

Before and after Training.indd :43:56

Block Overview Block-Übersicht for PlanMill

COMP9444 Neural Networks and Deep Learning 5. Convolutional Networks

VDE Prüf- und Zertifizierungsinstitut

Genotoxicity of 2-Hydroxy-1,4-naphthoquinone (Lawsone, CAS )

Assessment of studies on the health risk from particle matter (PM <2.5) from car emissions in relation to other risks in the study population

On cyclophysis and topophysis

SUSPECT ADVERSE REACTION REPORT

Review Questions in Introductory Knowledge... 37

Cognitive Systems. Grundlagen der Informationsverarbeitung in natürlichen und künstlichen Systemen

Chapter 11 Multiway Search Trees

Science Misconduct: Detection and Risk Mitigation

Calibration Flow meters for liquids and gases. Testo Industrial Services More assurance, better service.

ARTICLE IN PRESS. Margaret Hidderley a, *, Martin Holt b

A Guide to Algorithm Design: Paradigms, Methods, and Complexity Analysis

SUSPECT ADVERSE REACTION REPORT

Diameter reduction of the great saphenous vein and the common femoral vein after CHIVA

SUSPECT ADVERSE REACTION REPORT

Central Algorithmic Techniques. Iterative Algorithms

Problem Solving Agents

Aymeé Michel de Arévalo Phytosterol enrichment in vegetable oil by high pressure processing

25 Things To Know. Neurons

SUSPECT ADVERSE REACTION REPORT

Positive Psychotherapy. on the Pulse of Time. Dear colleagues,

SIL Declaration of Conformity / SIL Konformitätserklärung

Phylogenetic Methods

Contribution and interaction of visual and vestibular cues for spatial updating in real and virtual environments

Download Prions In Humans And Animals pdf

SUSPECT ADVERSE REACTION REPORT

Radiation Protection Principles for Radioiodine Therapy

A Puff-by-Puff Delivery Model for Cigarettes*

Diffusion across a Selectively Permeable Membrane

Do Proposers Expect Groups to Play More "Rational" Than Individuals? Evidence From an Ultimatum Game Experiment

ACUPUNCTURE WITH RADIAL SHOCK WAVE TECHNOLOGY

SUSPECT ADVERSE REACTION REPORT

THE QUICK BROWN FOX Jumps over the lazy dog. 1. The quick brown fox jumps over the lazy dog

Facts about the harm of Fast Food

Solving problems by searching

Cochrane Reviews für den Fachbereich Ergotherapie

At The University of Wisconsin, Dr. Frederick Crane s discovery of ubiquinone in heart

Road safety for young drivers

Gerrig Zimbardo Psychologie

INTERNATIONALES MARKENMANAGEMENT

Ex post evaluation South Africa

Projects: Neoplasms benign, malignant and unspecified (incl cysts and polyps)

Maximum Likelihood ofevolutionary Trees is Hard p.1

Clinical Trial Service Unit, University of Oxford, Oxford. ACST-2 an update

Testosterone and obesity. Referent Prof. Dr. Michael Zitzmann

Safe Reinforcement Learning and the Future of ISO 26262

Cochrane Reviews für den Fachbereich Physiotherapie

Grassroots Advocacy; Hope, Resources, Support. Muffy Walker MBA, MSN

Bargaining about Time: Evidence from Dictator and Ultimatum Games. Roger Berger & Sandra Prade

Leman Akoglu Hanghang Tong Jilles Vreeken. Polo Chau Nikolaj Tatti Christos Faloutsos SIAM International Conference on Data Mining (SDM 2013)

NG U TO D TOCKPHO A is L IN E UPDATE IN GI ONCOLOGY 01. MÄRZ 2019, WIEN

IMRT FOR CRANIOSPINAL IRRADIATION: CHALLENGES AND RESULTS. A. Miller, L. Kasulaitytė Institute of Oncolygy, Vilnius University

PRINCESSA: Erstellung eines R-Paketes und einer zugehörigen Web-Applikation zur ProteinCoexpressions-Analyse

IAT 355 Visual Analytics. Encoding Information: Design. Lyn Bartram

Auswertungsbericht Lehrveranstaltungsevaluation an die Lehrenden

Imaging spot weld inspection using Phased Array technology new features and correlation to destructive testing

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2014

Benefit-Risk assessment of vaccines, the perspective of a European regulatory agency

USE OF CT1341 ANAESTHETIC ('SAFFAN') IN MONKEYS

Termination of atrial flutter by directed transesophageal atrial pacing during transesophageal echocardiography

Cochrane Reviews für den Fachbereich Physiotherapie

SUSPECT ADVERSE REACTION REPORT

Eye-tracking test design influences the relationship between gazing behaviour and evaluation decision

The Effect of an Irrelevant Premise on Temporal and Spatial Reasoning

Personal Information. Academic Employment

SD4. SD 4 Anfang Monoblockventile P. Position 1. Position 0 (45.5) Position

6159 The Moon of Valencia

Exploration and Exploitation in Reinforcement Learning

SUMMARY RECORD OF THE STANDING COMMITTEE ON THE FOOD CHAIN AND ANIMAL HEALTH HELD ON 20 MARCH 2007 IN BRUSSELS

Reactive agents and perceptual ambiguity

SUSPECT ADVERSE REACTION REPORT

Modeling Natural Selection Activity

Drug Checking - Interaction with service users The effects of drug checking on information giving and counselling

Stadien der Progression bei CKD

The Precision of Clinical Estriol and Total Estrogen Estimations in Pregnancy Urine

Survey programme for Avian Influenza

An Improved UV-Spectrophotometric Method for Routine Barbiturate Monitoring

Angelman-Syndrom: Forschungsarbeit und klinische Studie. Edwin J Weeber, Ph.D.

Transcription:

German Collegiate Programming Contest GCPC Jury gcpc@nwerc.eu 2. Juli 2011 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 1 / 23

jury sample solutions Problem min. LOC max. LOC Faculty Dividing Powers 31 54 Genetic Fraud 32 48 Indiana Jones and the lost Soccer Cup 50 60 Magic Star 49 74 Magical Crafting 46 93 My brother s diary 31 47 Security Zone 67 199 Sightseeing 34 113 Suiting Weavers 88 179 Time to live 32 65 460 932 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 2 / 23

Faculty Dividing Powers Given n and k, find max { i k i divides n! } GCPC Jury German Collegiate Programming Contest 2. Juli 2011 3 / 23

Faculty Dividing Powers Given n and k, find max { i k i divides n! } Consider prime factorizations of n! and k: n! = p n 1 1 pn 2 2 pn 3 3... k = p k 1 1 pk 2 2 pk 3 3... GCPC Jury German Collegiate Programming Contest 2. Juli 2011 3 / 23

Faculty Dividing Powers Given n and k, find max { i k i divides n! } Consider prime factorizations of n! and k: n! = p n 1 1 pn 2 2 pn 3 3... k = p k 1 1 pk 2 2 pk 3 3... Then k i = p ik 1 1 p ik 2 2 p ik 3 3... and we require ik 1 n 1, ik 2 n 2, ik 3 n 3,... GCPC Jury German Collegiate Programming Contest 2. Juli 2011 3 / 23

Faculty Dividing Powers Given n and k, find max { i k i divides n! } Consider prime factorizations of n! and k: n! = p n 1 1 pn 2 2 pn 3 3... k = p k 1 1 pk 2 2 pk 3 3... Then k i = p ik 1 1 p ik 2 2 p ik 3 3... and we require ik 1 n 1, ik 2 n 2, ik 3 n 3,... So solution is min i 1,ki >0 { n i /k i } GCPC Jury German Collegiate Programming Contest 2. Juli 2011 3 / 23

Faculty Dividing Powers Find prime factorization of k in time O( k) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 4 / 23

Faculty Dividing Powers Find prime factorization of k in time O( k) For each prime factor p of k, find out how often p divides n! by the following formula: n p + n p 2 + n p 3 +... GCPC Jury German Collegiate Programming Contest 2. Juli 2011 4 / 23

Faculty Dividing Powers Find prime factorization of k in time O( k) For each prime factor p of k, find out how often p divides n! by the following formula: n p + n p 2 + n p 3 +... Number of prime factors is O(log k), evaluating the formula takes time O(log n) for each one GCPC Jury German Collegiate Programming Contest 2. Juli 2011 4 / 23

Faculty Dividing Powers Find prime factorization of k in time O( k) For each prime factor p of k, find out how often p divides n! by the following formula: n p + n p 2 + n p 3 +... Number of prime factors is O(log k), evaluating the formula takes time O(log n) for each one So whole runtime is O( k + log k log n) Mistakes: Scanner.nextInt() while(ktmp =n) vs. while(ktmp =n/primes[m].first) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 4 / 23

Faculty Dividing Powers Example: n = 15, k = 12 k = 12 = 2 2 3 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 1 x x x x x x x 2 2 x x x 2 3 x 3 1 x x x x x 3 2 x n! contains 2 11 3 6 i = min( 11 2, 6 1 ) = 5 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 5 / 23

Genetic Fraud Gegeben sind zwei Strings aus Kleinbuchstaben Die Frage ist ob eine Subsequenz der Länge L/2 oder r existiert, bei der leichte Fehler (+/- 1) erlaubt sind GCPC Jury German Collegiate Programming Contest 2. Juli 2011 6 / 23

Genetic Fraud Gegeben sind zwei Strings aus Kleinbuchstaben Die Frage ist ob eine Subsequenz der Länge L/2 oder r existiert, bei der leichte Fehler (+/- 1) erlaubt sind Zur Lösung reicht das Standardverfahren für LCS (dynamische Programmierung) ebenfalls aus Problematisch konnte hauptsächlich Division durch zwei werden durch fehlerhaften Testinput: Greedy wurde auch akzeptiert GCPC Jury German Collegiate Programming Contest 2. Juli 2011 6 / 23

Indiana Jones Standard topological sort GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Indiana Jones Standard topological sort Remove nodes with indegree 0 one by one, until there s none left (including out-going edges) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Indiana Jones Standard topological sort Remove nodes with indegree 0 one by one, until there s none left (including out-going edges) If not all nodes have been removed, output recheck hints GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Indiana Jones Standard topological sort Remove nodes with indegree 0 one by one, until there s none left (including out-going edges) If not all nodes have been removed, output recheck hints If all nodes have been removed, but at one point there was more than one node with indegree 0, output missing hints GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Indiana Jones Standard topological sort Remove nodes with indegree 0 one by one, until there s none left (including out-going edges) If not all nodes have been removed, output recheck hints If all nodes have been removed, but at one point there was more than one node with indegree 0, output missing hints Else output nodes in the order they were removed GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Indiana Jones Standard topological sort Remove nodes with indegree 0 one by one, until there s none left (including out-going edges) If not all nodes have been removed, output recheck hints If all nodes have been removed, but at one point there was more than one node with indegree 0, output missing hints Else output nodes in the order they were removed common mistake: stopped immediately once more than one node with indegree 0 was available, instead of checking whether all nodes will be removed GCPC Jury German Collegiate Programming Contest 2. Juli 2011 7 / 23

Magic Star Simple backtracking runs in time. There are fewer than 12 8 solutions (when you place three values in a row, the fourth is determined). The real number of possible solutions is considerably smaller. GCPC Jury German Collegiate Programming Contest 2. Juli 2011 8 / 23

Magic Star Simple backtracking runs in time. There are fewer than 12 8 solutions (when you place three values in a row, the fourth is determined). The real number of possible solutions is considerably smaller. Construct all possible solutions and select the lexicographically smallest one. GCPC Jury German Collegiate Programming Contest 2. Juli 2011 8 / 23

Magic Star Simple backtracking runs in time. There are fewer than 12 8 solutions (when you place three values in a row, the fourth is determined). The real number of possible solutions is considerably smaller. Construct all possible solutions and select the lexicographically smallest one. Better: construct the solutions in lexicographical order, then you can stop as soon as the first solution is found. GCPC Jury German Collegiate Programming Contest 2. Juli 2011 8 / 23

Magical Crafting Gegeben ist ein Set von Rezepten und ein Leuchteffekt Herauszufinden ist, ob ein Leuchteffekt aus den Rezepten erstellt werden kann...... und wenn ja, mit welchen Kosten GCPC Jury German Collegiate Programming Contest 2. Juli 2011 9 / 23

Magical Crafting Gegeben ist ein Set von Rezepten und ein Leuchteffekt Herauszufinden ist, ob ein Leuchteffekt aus den Rezepten erstellt werden kann...... und wenn ja, mit welchen Kosten Die Rezepte sind Regeln einer Grammatik in (beinahe) Chomsky Normalform Der CYK Algorithmus berechnet die Möglichkeit Erweitert um den Kostenfaktor liefert er auch die minimale Anzahl Diamanten GCPC Jury German Collegiate Programming Contest 2. Juli 2011 9 / 23

My brother s diary No-Brainer count letter frequencies is the most frequent letter unique? shift distance d is calculated by (26 + (maxchar E ))%26 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 10 / 23

My brother s diary No-Brainer count letter frequencies is the most frequent letter unique? shift distance d is calculated by (26 + (maxchar E ))%26 calculated correct distance d, but not in interval 0 d 25 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 10 / 23

Security Zone reduction to two circles: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 11 / 23

Security Zone reduction to two circles: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 12 / 23

Security Zone reduction to two circles: w 2 = arccos( r 2 r 1 d ) w 1 = π arccos( r 2 r 1 d ) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 12 / 23

Security Zone reduction to two circles: w 2 = arccos( r 2 r 1 d ) w 1 = π arccos( r 2 r 1 d ) = arccos( r 1 r 2 d ) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 12 / 23

Security Zone algorithm for arbitrary number of circles: (compute convex hull by wrapping around circles) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 13 / 23

Security Zone algorithm for arbitrary number of circles: (compute convex hull by wrapping around circles) search start point (circle + angle) GCPC Jury German Collegiate Programming Contest 2. Juli 2011 13 / 23

Security Zone algorithm for arbitrary number of circles: (compute convex hull by wrapping around circles) search start point (circle + angle) while not finished: iterate over other every circle and search for next angle / transition to other circle GCPC Jury German Collegiate Programming Contest 2. Juli 2011 13 / 23

Security Zone algorithm for arbitrary number of circles: (compute convex hull by wrapping around circles) search start point (circle + angle) while not finished: iterate over other every circle and search for next angle / transition to other circle add radial part between last angle and next angle GCPC Jury German Collegiate Programming Contest 2. Juli 2011 13 / 23

Security Zone algorithm for arbitrary number of circles: (compute convex hull by wrapping around circles) search start point (circle + angle) while not finished: iterate over other every circle and search for next angle / transition to other circle add radial part between last angle and next angle add distance between the two points on the corresponding two circles GCPC Jury German Collegiate Programming Contest 2. Juli 2011 13 / 23

Security Zone example: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 14 / 23

Security Zone example: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 14 / 23

Security Zone example: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 14 / 23

Security Zone example: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 14 / 23

Security Zone example: GCPC Jury German Collegiate Programming Contest 2. Juli 2011 14 / 23

Security Zone common mistake: you did not submit GCPC Jury German Collegiate Programming Contest 2. Juli 2011 15 / 23

Sightseeing Gesucht ist eine kürzeste Route über ein zirkuläres Set von Strecken Keine der Strecken darf dabei mehrfach durchlaufen werden GCPC Jury German Collegiate Programming Contest 2. Juli 2011 16 / 23

Sightseeing Gesucht ist eine kürzeste Route über ein zirkuläres Set von Strecken Keine der Strecken darf dabei mehrfach durchlaufen werden Bei bekanntem Startpunkt lässt sich der kürzeste Weg in Linearzeit berechnen (Simple Graphstruktur) Simulation durch Dynamische Programmierung Die Strecke musste vom Ziel her rekonstruiert werden Auch ausreichend: Dijkstra Algorithmus Integer Überläufe konnten richtige Zeit voräuschen GCPC Jury German Collegiate Programming Contest 2. Juli 2011 16 / 23

Suiting Weavers Problem Possible to assign fibers to weavers, so that no weaver has more fibers than Willy? General Approach Willy picks up all fibers he can reach Calculate maximum fibers that each weaver may pick up not surpassing Willy Use maximum flow algorithm to decide GCPC Jury German Collegiate Programming Contest 2. Juli 2011 17 / 23

Suiting Weavers (2) Assume Willy collects all fibers in reach Find these places Assign fibers to Willy This gives Willy s optimum number of fibers W Shortcut: If there exists a weaver with more than W fibers Lonesome Willy GCPC Jury German Collegiate Programming Contest 2. Juli 2011 18 / 23

Suiting Weavers (3) Maximum flow network One node for each remaining place and weaver, an additional source and a sink Edges From each place to weavers that can reach it Capacity: number of fibers (or ) From source to each place Capacity: number of fibers of the place From all weavers to sink Capacity: difference of W and the initial number of fibers collected by the corresponding weaver max. flow = f i Suiting Success i.e., all remaining fibers were assigned GCPC Jury German Collegiate Programming Contest 2. Juli 2011 19 / 23

Time To Live given: tree find: node X (resp. path length) the path length from any node in the tree to X should be minimized a b c d e f g h i j k l m n GCPC Jury German Collegiate Programming Contest 2. Juli 2011 20 / 23

Time To Live compute length l of longest path in tree, answer: (l + 1)/2 do BFS from arbitrary root first, then do BFS from last node in previous BFS a b c d e f g h i j k l m n GCPC Jury German Collegiate Programming Contest 2. Juli 2011 21 / 23

Time To Live compute length l of longest path in tree, answer: (l + 1)/2 do BFS from arbitrary root first, then do BFS from last node in previous BFS a b c d e f g h i j k l m n GCPC Jury German Collegiate Programming Contest 2. Juli 2011 21 / 23

Time To Live compute length l of longest path in tree, answer: (l + 1)/2 do BFS from arbitrary root first, then do BFS from last node in previous BFS a b c d e f g h i j k l m n GCPC Jury German Collegiate Programming Contest 2. Juli 2011 21 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) a b c d e f g h i j k l m n GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) a b c 0 e f g 0 i j k 0 0 0 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) a 1 c 0 e f g 0 i 1 1 0 0 0 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) 2 1 c 0 e f 2 0 2 1 1 0 0 0 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) 2 1 0 c 3 3 2 0 2 1 1 0 0 0 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Time To Live alternative: number layers in tree leafs on layer 0, other nodes on layer 1 + max(successors) 2 1 4 0 3 3 2 0 2 1 1 0 0 0 GCPC Jury German Collegiate Programming Contest 2. Juli 2011 22 / 23

Award Ceremony GCPC Jury German Collegiate Programming Contest 2. Juli 2011 23 / 23