competition programming n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Competition Programming PowerPoint Presentation
Download Presentation
Competition Programming

Loading in 2 Seconds...

play fullscreen
1 / 14

Competition Programming - PowerPoint PPT Presentation


  • 116 Views
  • Uploaded on

Competition Programming. Analyzing and Solving problems. Steps in solving a problem. Reading the problem Formulation of a solution Implementation the solution Testing the solution. Reading the problem. Read the WHOLE problem!

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Competition Programming' - prisca


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
competition programming

Competition Programming

Analyzing and Solving problems

Christopher Moh 2005

steps in solving a problem
Steps in solving a problem
  • Reading the problem
  • Formulation of a solution
  • Implementation the solution
  • Testing the solution

Christopher Moh 2005

reading the problem
Reading the problem
  • Read the WHOLE problem!
    • May have subtle details in problem descriptions that are essential to solve the problem efficiently
  • Examining Time and Space constraints
  • Watching out for obvious properties

Christopher Moh 2005

time and space constraints
Time and Space Constraints
  • Time Constraints usually are more important than Space Constraints
  • What kind of algorithm works?
    • Good average case?
    • Good worst case?
  • Gives an idea of the kind of algorithm that solves the problem
    • E.g. Huge graph problems usually imply some linear-time traversal solution

Christopher Moh 2005

time and space constraints1
Time and Space Constraints
  • Does the problem specify the size of the test cases?
    • If there are only one or two test cases that are huge compared to the rest…
      • DON’T SOLVE FOR THESE TEST CASES IF YOU DON’T KNOW THE ADVANCED ALGORITHM
      • There usually will be a basic algorithm that will solve the rest with suitable optimizations and data structures

Christopher Moh 2005

properties i
Properties I
  • What unique properties are explicitly stated or easily implied?
    • Unique Numbers?
    • At most one path between any two nodes implies a forest of trees
    • Exactly one path between any two nodes implies a tree
    • No return path may imply a DAG
    • Classification in a system of “black” and “white” etc may imply a bipartite graph

Christopher Moh 2005

formulation
Formulation
  • How can I solve this problem?
    • As a Graph problem?
    • As a DP problem?
    • Sorting problem?
    • Clever data structures?
    • Using unique properties of the problem?
    • Brute Force?

Christopher Moh 2005

breaking down problems
Breaking down problems
  • Can this problem be broken down into a decent number of sub-problems that can be combined to solve the problem?
  • Is there an inherent, or maybe a subtle implied order that we can use?
  • Can I use a solution to a similar problem of a smaller dimension?

Christopher Moh 2005

properties ii
Properties II
  • Are there number properties I can use?
  • Is this a special graph with unique properties e.g. trees, DAGs, etc.?
  • Is sorting allowed and what advantage can sorting give me?
    • Does a greedy solution work?

Christopher Moh 2005

implementation
Implementation
  • Data Structures
    • Can I get away with using simple data structures and still beat the time limit?
    • If not, what works?
      • Heaps?
      • Interval trees?
      • Cumulative Sum data structures? [ See IOI 2001 Day 1 Q1 ]

Christopher Moh 2005

implementation1
Implementation
  • Dynamic Programming solution
    • What do I have to keep track of?
    • How can I evaluate the recurrence relation? How should my loops be oriented?
    • Do I have to keep track of the solution if I need to backtrack to output the actual solution instead of the optimal result?
    • Should I use memoization?
    • Is there an important space constraint?

Christopher Moh 2005

implementation2
Implementation
  • Graph solutions
    • Should I use an adjacency list or a matrix?
      • Space and time constraints
    • Is my graph formulation solvable in polynomial time?
    • How many vertices/edges does my formulation produce? Is there a way to compress vertices/edges to improve runtime while still preserving accuracy of output?

Christopher Moh 2005

implementation3
Implementation
  • Brute Force solutions
    • What pruning methods are available?
    • Are there ways to generate output without going through redundancy or irrelevant search areas? [ See IOI 2001 Day 2 Q3 ]
    • Can a simple backtracking work? Or perhaps more advanced search methods e.g. Iterative Deepening, A* search are needed?

Christopher Moh 2005

testing
Testing
  • Testing for Accuracy with extreme cases
    • Isolated vertices?
    • Complete graphs?
    • Completely negative numbers?
  • Testing for Speed
    • How fast does the solution run when faced with a huge input?

Christopher Moh 2005