Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
80Activity
0 of .
Results for:
No results containing your search query
P. 1
The Hitchhiker’s Guide to the Programming Contests

The Hitchhiker’s Guide to the Programming Contests

Ratings:

5.0

(1)
|Views: 17,819|Likes:
Published by dpiklu

More info:

Published by: dpiklu on Feb 08, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/11/2014

pdf

text

original

 
The Hitchhiker’s Guide tothe Programming Contests
D
o
anic
 
Nite Nimajneb
 
Contents
1 Dynamic Programming 1
1.1 Subset Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 The Longest Increasing Subsequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Longest Common Subsequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 Reduce the Space to One Dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Max Sum on a Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.5 The Best Triangulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.6 Counting or Optimizing Good Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Graphs 5
2.1 Breadth First Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Depth First Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2.1 Topological Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2 Strongly Connected Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.3 Cut Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.3 Shortest Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.3.1 Bellman-Ford . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.3.2 Floyd-Warshall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3.3 Dijkstra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3.4 The Shortest Path DAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.4 Counting the Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.5 The Minimum Average Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.6 The Minimum Spanning Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 Bipartite Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.8 Maximum Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.9 Minimum (Maximum) Cost Bipartite Matching . . . . . . . . . . . . . . . . . . . . . . . . . . 212.10 Minimum Cost (Maximum Prot) Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3 Numbers 22
3.1 the Greatest Common Divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2 Generating the Prime Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.3 Repeated Squaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.4 Long Integers using Character Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.5 Fractional Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4 Algebra 31
4.1 the Matrix Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.2 the Method of Relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5 Geometry 35
5.1 the Geometry Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2 Some Geometric Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6 Miscellaneous 47
6.1 Binary Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.2 Range Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.3 Set Union and Find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486.4 String Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496.5 2D Arrays, Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506.5.1 Cover the Chessboard with Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . 50i

Activity (80)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
roxxy2008 liked this
6complex liked this
6complex liked this
John K Samuel liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->