1 / 23

Aufgabenbesprechung Programming Contest

Aufgabenbesprechung Programming Contest. 7 Bo Pat Jean Kevin Claude William Marybeth 6 Jim Ben Zoe Joey Frederick Annabelle 0. SET 1 Bo Jean Claude Marybeth William Kevin Pat SET 2 Jim Zoe Frederick Annabelle Joey Ben. Order. Order.

sbond
Download Presentation

Aufgabenbesprechung Programming Contest

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AufgabenbesprechungProgramming Contest

  2. 7 Bo Pat Jean Kevin Claude William Marybeth 6 Jim Ben Zoe Joey Frederick Annabelle 0 SET 1 Bo Jean Claude Marybeth William Kevin Pat SET 2 Jim Zoe Frederick Annabelle Joey Ben Order

  3. Order • Input: The input consists of one or more sets of strings, followed by a final line containing only the value 0. Each set starts with a line containing an integer, n, which is the number of strings in the set, followed by n strings, one per line, sorted in nondescending order by length. None of the strings contain spaces. There is at least one and no more than 15 strings per set. Each string is at most 25 characters long. • Output: For each input set print "SET n" on a line, where n starts at 1, followed by the output set as shown in the sample output.

  4. Speed • 2 * 20 + (6-2) * 30 + (7-6) * 10 = 170 • 1 * 60 + (5-1) * 30 = 180 • 1 * 15 + (2-1) * 25 + (3-2) * 30 + (5-3) * 10 = 90

  5. Speed • Input: The input consists of one or more data sets. Each set starts with a line containing an integer n, 1 ≤ n ≤ 10, followed by n pairs of values, one pair per line. The first value in a pair, s, is the speed in miles per hour and the second value, t, is the total elapsed time. Both s and t are integers, 1 ≤ s ≤ 90 and 1 ≤ t ≤ 12. The values for t are always in strictly increasing order. A value of -1 for n signals the end of the input. • Output: For each input set, print the distance driven, followed by a space, followed by the word "miles".

  6. Longnight • The input contains several test cases. The first line of a test case contains one integer N, which indicates the number of museums participating in the event (1 <= N <= 20). The second line of a test case contains N integers indicating the time, in minutes, needed to visit each museum. Then there are N lines describing the times to go from one museum to every other. You may assume that the i-th integer in the i-th line is equal to zero. The end of input is indicated by N = 0 • For each test case in the input, your program must produce one line containing the maximum number of museums that can be visited during the Long Night of Museums.

  7. Longnight

  8. Einlesen:

  9. Version 1 - Klassische Tiefensuche

  10. Problem zu langsam! • Wie langsam? => • Summe(i=1..20, i!) 2561327494111820313 Mögliche Kombinationen • Was tun? Bereits besuchte Kombinationen nicht nochmal machen! • Summe(i=1..20, 20 über i) = 1048575 • (SIC!)

  11. Wie verwalten? • int als Bitvector nutzen: • 5 Museen  5bits benötigt • War in 0, 2 und 3: 01101 (von rechts nach links lesen). • Bits gezielt anschalten: 00000 | 00001 = 00001 00101 | 01000 = 01101 • Wie bekommt man 01000 => 1 << 3

  12. kombination[i][j] == war ich schon mal in Museum i und habe die Kombination j bereits besucht gehabt

  13. Stimmt das? Mh... Ich bin nicht so sicher...

  14. Tax • ICPC needs to divide it into lots. • land can only be divided using a sequence of land divisions; • a land division is an operation that divides one piece of land into two pieces of land; and • for each land division, a land division tax must be paid. • Denoting by A the area of the largest resulting part of the division, the value of the land division tax is A×F, where F is the division tax factor.

  15. Beispiel

  16. Ansatz • Man muss alles durchprobieren. • Aber wieder schlau! => Dynamisches Programmieren: • Lege Datenstruktur an, die enthält wie man eine Teilfläche am billigsten in die gewünschten Teile zerlegen kann. • int[][] cost • cost[a][b] == Kosten zum Zerteilen von A bis B

  17. Grandpa

  18. Magic

  19. Tipps für Magic • Riesige Fallunterscheidung! • Einfacher mit indexOf

  20. Umgekehrt ist dann auch einfacher. CharAt verwenden "ABCDEF".charAt(3) == ? "ABCDEF".indexOf('E') == ? Tipps für Magic

More Related