ACM ICPC — Training Session IV C. Maria Keet A–Fair Division

ACM ICPC — Training Session IV

B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

C. Maria Keet Department of Computer Science, University of Cape Town, South Africa [email protected]

September 13, 2014

H–Stock Prices I–Telephone Network J–Wormly 1 / 21

Today ACM ICPC — Training Session IV C. Maria Keet A–Fair Division

NWERC 2010 Regional

B–Free Goodies

Try to solve as many as possible in 3.5h

C–High Score

Then we’ll discuss the solutions1 (approach & the code)

D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices I–Telephone Network 1

J–Wormly

The remainder of these slides are based on the Jury’s slides, with some additions and rewording for training purposes 2 / 21

Problem A–Fair Division ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

Sort persons according to maximum contribution Tie-breaker: position in list Multiples of 1 cent (integers) If dividing according to the rules is not possible (i.e., if sum < P), then print this else: the contribution is min(max[i], price/(N-i)) for i=0...N-1

H–Stock Prices I–Telephone Network J–Wormly 3 / 21

Problem B–Free Goodies ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score

Requested: total value of goodies for each Petra chooses “most valuable”. greedy? “ties”: dynamic programming?

E–Rankings

Jan with “multiple choice lead to same optimal result”. dynamic programming?

F–Risk

Sort goodies based on Petra’s valuations (why not Jan’s?)

G–Selling Land

Then popping the queue, and adding up the values

D–Hill Driving

H–Stock Prices I–Telephone Network J–Wormly 4 / 21

Problem C–High Score ACM ICPC — Training Session IV C. Maria Keet

e.g., start with AAA and end with JAN A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

first count from A to J (9 steps), then move to third (1 step to the left), and then A to N (13 steps).

For a next letter to update, can we continue where we ‘left off’ ? say, having counted from A to J, then move to third (1 step to the left), and then J to N??

Loops turning around over the name and over the alphabet Count number of steps for each character, starting from A

I–Telephone Network J–Wormly 5 / 21

Problem C–High Score ACM ICPC — Training Session IV C. Maria Keet

e.g., start with AAA and end with JAN A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

first count from A to J (9 steps), then move to third (1 step to the left), and then A to N (13 steps).

For a next letter to update, can we continue where we ‘left off’ ? say, having counted from A to J, then move to third (1 step to the left), and then J to N??

Loops turning around over the name and over the alphabet Count number of steps for each character, starting from A

I–Telephone Network J–Wormly 6 / 21

Problem D–Hill Driving ACM ICPC — Training Session IV C. Maria Keet

Flat land: same speed

A–Fair Division

Downhill section: 10 km/h, no fuel consumption

B–Free Goodies

Uphill section: fuel consumption as if you were driving 10 km/h faster

C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

Task: calculate time it takes to arrive home (≤24h), or impossible. Linear search to crunch through the segments and update, or binary search to cut it off earlier if it would be impossible

I–Telephone Network J–Wormly 7 / 21

Problem D–Hill Driving ACM ICPC — Training Session IV C. Maria Keet

Flat land: same speed

A–Fair Division

Downhill section: 10 km/h, no fuel consumption

B–Free Goodies

Uphill section: fuel consumption as if you were driving 10 km/h faster

C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

Task: calculate time it takes to arrive home (≤24h), or impossible. Linear search to crunch through the segments and update, or binary search to cut it off earlier if it would be impossible

I–Telephone Network J–Wormly 8 / 21

Problem D–Hill Driving ACM ICPC — Training Session IV C. Maria Keet

Flat land: same speed

A–Fair Division

Downhill section: 10 km/h, no fuel consumption

B–Free Goodies

Uphill section: fuel consumption as if you were driving 10 km/h faster

C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

Task: calculate time it takes to arrive home (≤24h), or impossible. Linear search to crunch through the segments and update, or binary search to cut it off earlier if it would be impossible

I–Telephone Network J–Wormly 9 / 21

Problem E–Rankings ACM ICPC — Training Session IV C. Maria Keet A–Fair Division

Take last year’s ranking as starting point for computing this year’s ranking

B–Free Goodies

Sort swaps along ranking

C–High Score

Do the swaps Check consistency old v.s. new ranking; e.g.,

D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

ranking 1 2 3 4 swaps 1 2, then 2 3, and finally 3 4 results in 2 1 3 4 - 3 1 2 4 - 4 1 2 3 4 1 2 3 violates swap 1 2

I–Telephone Network J–Wormly 10 / 21

Problem F–Risk ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

Don’t get sidetracked with the rules of the actual game.... (like whether the amount of moves has to match the total number of the dice you throw—that info is not in the input) First: find the ‘weakest region’ bordering an opponent. quickest: binary search There is a maximum flow algorithm to determine if the answer is possible

H–Stock Prices I–Telephone Network J–Wormly 11 / 21

Problem F–Risk ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

Don’t get sidetracked with the rules of the actual game.... (like whether the amount of moves has to match the total number of the dice you throw—that info is not in the input) First: find the ‘weakest region’ bordering an opponent. quickest: binary search There is a maximum flow algorithm to determine if the answer is possible

H–Stock Prices I–Telephone Network J–Wormly 12 / 21

Problem F–Risk ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

Set up graph vertices: the source with the armies, the sink where they have to go to (region bordering opponent’s region with least armies), and 2 vertices for each land you control (which text in the description says that?) Graph edges: source → 1st land (cap is the number of armies) 1st land → 2nd land (if connected) 2nd land → sink (cap is the needed armies)

H–Stock Prices I–Telephone Network J–Wormly 13 / 21

Problem G–Selling Land ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score

Perhaps ‘confusing’ part is not calculating number of cells, but perimeter values south-east corner cell no more than once Find the number of single cells (perimeter 4) Find the number of 2-cells (perimeter 6)

D–Hill Driving E–Rankings

etc.

F–Risk

Do that by scanning row-by-row

G–Selling Land H–Stock Prices I–Telephone Network

For each column c of row r , count the number of grass squares above (c, r ) Process columns and keep a list of possible end squares

J–Wormly 14 / 21

Problem G–Selling Land ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score

Perhaps ‘confusing’ part is not calculating number of cells, but perimeter values south-east corner cell no more than once Find the number of single cells (perimeter 4) Find the number of 2-cells (perimeter 6)

D–Hill Driving E–Rankings

etc.

F–Risk

Do that by scanning row-by-row

G–Selling Land H–Stock Prices I–Telephone Network

For each column c of row r , count the number of grass squares above (c, r ) Process columns and keep a list of possible end squares

J–Wormly 15 / 21

Problem H–Stock Prices ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land H–Stock Prices

make an array with ask (sell price), bid (buy price), stock (sold), amounts as columns, against the n transaction steps process each input line of the test case one at a time: While bid price larger than ask price, process deal up to min(amount-ask, amount-bid) number of shares update amounts, stock price output prices or a dash if it doesn’t exist, in requested format

I–Telephone Network J–Wormly 16 / 21

I–Telephone Network ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving E–Rankings F–Risk G–Selling Land

All sets of requests are possible, so we can add dummy requests to get bipartite graph with deg (v ) = 1 for all v Reduce this graph modulo 2n−1 to get a bipartite graph with deg (v ) = 2 for all v Split this graph in two graphs with all degrees 1 and you get two instances of the same problem with n0 = n/2 Solve recursively and construct solution

H–Stock Prices I–Telephone Network J–Wormly 17 / 21

J–Wormly ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving

With l, b, n ≤ 1000000, would brute force work, calculating all permutations? yes, but probably TLE would it make sense to search the entire search space to check?

F–Risk

better: use Greedy, moving first leg, then last leg, then the bubbles

G–Selling Land

repeat until finished

E–Rankings

H–Stock Prices I–Telephone Network J–Wormly 18 / 21

J–Wormly ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving

With l, b, n ≤ 1000000, would brute force work, calculating all permutations? yes, but probably TLE would it make sense to search the entire search space to check?

F–Risk

better: use Greedy, moving first leg, then last leg, then the bubbles

G–Selling Land

repeat until finished

E–Rankings

H–Stock Prices I–Telephone Network J–Wormly 19 / 21

J–Wormly ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies C–High Score D–Hill Driving

With l, b, n ≤ 1000000, would brute force work, calculating all permutations? yes, but probably TLE would it make sense to search the entire search space to check?

F–Risk

better: use Greedy, moving first leg, then last leg, then the bubbles

G–Selling Land

repeat until finished

E–Rankings

H–Stock Prices I–Telephone Network J–Wormly 20 / 21

Scheduled training dates ACM ICPC — Training Session IV C. Maria Keet A–Fair Division B–Free Goodies

Aug 2: 9:30-15:30 Aug 16: 9:30-15:30 Aug 30: 9:30-15:30

C–High Score D–Hill Driving

Sept 13: 9:30-15:30

E–Rankings

Sept 26: deadline for registering for the regionals

F–Risk

Sept 27: 9:30-15:30

G–Selling Land

Date of the regionals: 4 October, 2014

H–Stock Prices I–Telephone Network J–Wormly 21 / 21

ACM ICPC — Training Session IV - UCT

Sep 13, 2014 - Task: calculate time it takes to arrive home (≤24h), or impossible. Linear search to crunch through the segments and update, or binary search ...

170KB Sizes 2 Downloads 69 Views

Recommend Documents

ACM ICPC Greater New York Region Contest -
... will provide a space for about 150 motivated college students from the New York ... The top teams from this contest will be invited to compete in the 2017 ACM ICPC ... Each member of the organizing team has been involved in programming ... Reserv

Summary - ACM ICPC 2013 Dhaka Site.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Summary - ACM ...

Beech Session IV 16.17.pdf
KEYBOARD MASTERS (Gr. 3-5): Learn how to type by using a fun, online. typing program that will teach you how to type like a pro! Class Limit: 20. UNO CLUB ...

ACM International Collegiate Programming Contest — Training ...
Aug 16, 2014 - Student IDs. Railways ... Contest — Training Session II. C. Maria Keet. Department of Computer Science, University of Cape Town, South Africa.

Northwest Session IV 16.17.pdf
parents and a voicemail will be left if direct contact was not possible. ... Notification will be made through the school's standard procedure. In these cases ...

Northwest Session IV 17.18.pdf
the 21st CCLC program procedures, policies and expectations including the following: I understand that nursing services ... Activity Hour (Gr. K-1): Play games, share with friends, play outside. and enjoy your afternoon in a .... Street Address ...

ACM International Collegiate Programming Contest — Training ...
Aug 16, 2014 - b. conceptually (relatively) easy, but laborious to design and/or ... Competitive programming 1, by Steven and Felix Halim: https://sites.google.com/site/stevenhalim/. 6 / 33 ... Prim? Which one works best? or neither, and use another

ACM International Collegiate Programming Contest — Training ...
Aug 30, 2014 - Contest — Training Session III. C. Maria Keet. Department of Computer Science, University of Cape Town, South Africa [email protected].

ACM International Collegiate Programming Contest — Training ...
Aug 16, 2014 - Department of Computer Science, University of Cape Town, South Africa ..... BA from left to right, starting from position 3 and every other.

ACM International Collegiate Programming Contest — Training ...
Aug 30, 2014 - Identifying a CS 'problem-solving paradigm' from the ... content in this section based on “Competitive programming 1”, by Steven and Felix ...

UNIT IV BACKTRACKING Session –26
For each path from the starting point. check if selected path is safe, if yes select it and make recursive call to rest of the problem. If recursive calls return true, then.

ACM and ACM-W Schedule -
Karen Shanklin, Courtney Brazell, and Kristijana Arroyo will talk about their experiences at. Sandia, the Jill Hruby Fellowship, and the open source wave energy converter array simulation tool, SWAN. Female students are strongly encouraged to attend.

English session Mandarin session
If possible, please turn off phones and laptops. Toastmaster. Runs the meeting. Responsible for the agenda and confirming all meeting roles in advance.

Dysphagia - A training session for nursing homes.pdf
Dysphagia - A training session for nursing homes.pdf. Dysphagia - A training session for nursing homes.pdf. Open. Extract. Open with. Sign In. Main menu.

Electivos UCT 2016-2.pdf
... A -222 San Francisco Loreto Escalante/Marco Bellott loreto.escalante@gm ... A-222 San Francisco Jaime García/Nabil Rodriguez [email protected].

Trading Session- 1 Trading Session- 2 - NSE
Jun 2, 2018 - In continuation to our circular (Download No. ... Members are requested to refer circular no NSE/CD/37850 dated .... Primary (BKC) / DR site.

Trading Session- 1 Trading Session- 2 - NSE
Apr 27, 2018 - Mock trading on Saturday, May 05, 2018– No new version release ... conducting a mock trading session in the Futures & Options Segment on ...

Framework_Completion Part-Time Doctoral Studies ... - UCT Students
FRAMEWORK. Study Support for Completing. Part-time Doctoral Students. Directorate Human and Infrastructure Capacity Development. Date. July 2015 ...

uCT Data Science workshop -
8:30 AM – 9:15 AM. Registration and Coffee. 9:15 AM – 9:30 AM. Assoc Prof Francesca Little Head of the Department of Statistics, UCT. Speakers. 9:30 AM – 10:30 AM Dario Fanucchi. Isazi Consulting. Jasper Horrell. Deep Data. Rodney Morgan /. Wil

Framework_Completion Part-Time Doctoral Studies ... - UCT Students
part-time students, for dedicated time away from work pressures to complete their dissertations. The funding instrument aims to provide funding to part-time ...

Electivos UCT 2016-2.pdf
2 L 12:40-14:50 CT+102 Juan Pablo II Rodrigo Hiriarte/Hernan Vallejo. UCT058 Amor y Juventud 1 L 15:00-17:00 CT+204 Juan Pablo II Jessica Morales ...

Trading Session- 1 Trading Session- 2 - NSE
4 days ago - In view of the same, Exchange will be conducting a mock trading (contingency) session in the. Currency Derivatives Segment on Saturday, July ...

practice - ACM Digital Library
This article provides an overview of how XSS vulnerabilities arise and why it is so difficult to avoid them in real-world Web application software development.

MORNING SESSION
Apr 9, 2014 - Ministry of Information,. Youth, Culture and ... Performing Arts Department. 11.30-12.00 am ... SCIENCE AND TECHNOLOGY-. COSTECH.