/CSES-Solutions

Accepted Solutions to the CSES Competitive Programming Problem Set

Primary LanguageC++

CSES Solutions

Over 280 accepted solutions to the CSES Problem Set, written in C++ by Jonathan Uy (nulltype). As of December 23th, the following number of solutions have been completed:

Problem Type Number Solved
Introductory Problems 19/19
Sorting and Searching 35/35
Dynamic Programming 19/19
Graph Algorithms 36/36
Range Queries 19/19
Tree Algorithms 16/16
Mathematics 31/31
String Algorithms 17/17
Geometry 7/7
Advanced Techniques 24/24
Additional Problems 65/77
Total 288/300

Table of Contents

Introductory Problems

  1. Weird Algorithm
  2. Missing Number
  3. Repetitions
  4. Increasing Array
  5. Permutations
  6. Number Spiral
  7. Two Knights
  8. Two Sets
  9. Bit Strings
  10. Trailing Zeros
  11. Coin Piles
  12. Palindrome Reorder
  13. Gray Code
  14. Tower of Hanoi
  15. Creating Strings
  16. Apple Division
  17. Chessboard and Queens
  18. Digit Queries
  19. Grid Paths

Sorting and Searching

  1. Distinct Numbers
  2. Apartments
  3. Ferris Wheel
  4. Concert Tickets
  5. Restaurant Customers
  6. Movie Festival
  7. Sum of Two Values
  8. Maximum Subarray Sum
  9. Stick Lengths
  10. Missing Coin Sum
  11. Collecting Numbers
  12. Collecting Numbers II
  13. Playlist
  14. Towers
  15. Traffic Lights
  16. Josephus Problem I
  17. Josephus Problem II
  18. Nested Ranges Check
  19. Nested Ranges Count
  20. Room Allocation
  21. Factory Machines
  22. Tasks and Deadlines
  23. Reading Books
  24. Sum of Three Values
  25. Sum of Four Values
  26. Nearest Smaller Values
  27. Subarray Sums I
  28. Subarray Sums II
  29. Subarray Divisibility
  30. Subarray Distinct Values
  31. Array Division
  32. Sliding Median
  33. Sliding Cost
  34. Movie Festival II
  35. Maximum Subarray Sum II

Dynamic Programming

  1. Dice Combinations
  2. Minimizing Coins
  3. Coin Combinations I
  4. Coin Combinations II
  5. Removing Digits
  6. Grid Paths
  7. Book Shop
  8. Array Description
  9. Counting Towers
  10. Edit Distance
  11. Rectangle Cutting
  12. Money Sums
  13. Removal Game
  14. Two Sets II
  15. Increasing Subsequence
  16. Projects
  17. Elevator Rides
  18. Counting Tilings
  19. Counting Numbers

Graph Algorithms

  1. Counting Rooms
  2. Labyrinth
  3. Building Roads
  4. Message Route
  5. Building Teams
  6. Round Trip
  7. Monsters
  8. Shortest Routes I
  9. Shortest Routes II
  10. High Score
  11. Flight Discount
  12. Cycle Finding
  13. Flight Routes
  14. Round Trip II
  15. Course Schedule
  16. Longest Flight Route
  17. Game Routes
  18. Investigation
  19. Planets Queries I
  20. Planets Queries II
  21. Planets Cycles
  22. Road Reparation
  23. Road Construction
  24. Flight Routes Check
  25. Planets and Kingdoms
  26. Giant Pizza
  27. Coin Collector
  28. Mail Delivery
  29. De Bruijn Sequence
  30. Teleporters Path
  31. Hamiltonian Flights
  32. Knight's Tour
  33. Download Speed
  34. Police Chase
  35. School Dance
  36. Distinct Routes

Range Queries

  1. Static Range Sum Queries
  2. Static Range Minimum Queries
  3. Dynamic Range Sum Queries
  4. Dynamic Range Minimum Queries
  5. Range Xor Queries
  6. Range Update Queries
  7. Forest Queries
  8. Hotel Queries
  9. List Removals
  10. Salary Queries
  11. Prefix Sum Queries
  12. Pizzeria Queries
  13. Subarray Sum Queries
  14. Distinct Values Queries
  15. Increasing Array Queries
  16. Forest Queries II
  17. Range Updates and Sums
  18. Polynomial Queries
  19. Range Queries and Copies

Tree Algorithms

  1. Subordinates
  2. Tree Matching
  3. Tree Diameter
  4. Tree Distances I
  5. Tree Distances II
  6. Company Queries I
  7. Company Queries II
  8. Distance Queries
  9. Counting Paths
  10. Subtree Queries
  11. Path Queries
  12. Path Queries II
  13. Distinct Colors
  14. Finding a Centroid
  15. Fixed-Length Paths I
  16. Fixed-Length Paths II

Mathematics

  1. Josephus Queries
  2. Exponentiation
  3. Exponentiation II
  4. Counting Divisors
  5. Common Divisors
  6. Sum of Divisors
  7. Divisor Analysis
  8. Prime Multiples
  9. Counting Coprime Pairs
  10. Binomial Coefficients
  11. Creating Strings II
  12. Distributing Apples
  13. Christmas Party
  14. Bracket Sequences I
  15. Bracket Sequences II
  16. Counting Necklaces
  17. Counting Grids
  18. Fibonacci Numbers
  19. Throwing Dice
  20. Graph Paths I
  21. Graph Paths II
  22. Dice Probability
  23. Moving Robots
  24. Candy Lottery
  25. Inversion Probability
  26. Stick Game
  27. Nim Game I
  28. Nim Game II
  29. Stair Game
  30. Grundy's Game
  31. Another Game

String Algorithms

  1. Word Combinations
  2. String Matching
  3. Finding Borders
  4. Finding Periods
  5. Minimal Rotation
  6. Longest Palindrome
  7. Required Substring
  8. Palindrome Queries
  9. Finding Patterns
  10. Counting Patterns
  11. Pattern Positions
  12. Distinct Substrings
  13. Repeating Substring
  14. String Functions
  15. Substring Order I
  16. Substring Order II
  17. Substring Distribution

Geometry

  1. Point Location Test
  2. Line Segment Intersection
  3. Polygon Area
  4. Point in Polygon
  5. Polygon Lattice Points
  6. Minimum Euclidean Distance
  7. Convex Hull

Advanced Techniques

  1. Meet in the Middle
  2. Hamming Distance
  3. Beautiful Subgrids
  4. Reachable Nodes
  5. Reachability Queries
  6. Cut and Paste
  7. Substring Reversals
  8. Reversals and Sums
  9. Necessary Roads
  10. Necessary Cities
  11. Eulerian Subgraphs
  12. Monster Game I
  13. Monster Game II
  14. Subarray Squares
  15. Houses and Schools
  16. Knuth Division
  17. Apples and Bananas
  18. One Bit Positions
  19. Signal Processing
  20. New Roads Queries
  21. Dynamic Connectivity
  22. Parcel Delivery
  23. Task Assignment
  24. Distinct Routes II

Additional Problems

  1. Shortest Subsequence
  2. Counting Bits
  3. Swap Game
  4. Prüfer Code
  5. Acyclic Graph Edges
  6. Strongly Connected Edges
  7. Even Outdegree Edges
  8. Multiplication Table
  9. Advertisement
  10. Special Substrings
  11. Permutation Inversions
  12. Maximum Xor Subarray
  13. Movie Festival Queries
  14. Chess Tournament
  15. Tree Traversals
  16. Network Renovation
  17. Graph Girth
  18. Intersection Points
  19. Inverse Inversions
  20. Monotone Subsequences
  21. String Reorder
  22. Stack Weights
  23. Pyramid Array
  24. Increasing Subsequence II
  25. String Removals
  26. Bit Inversions
  27. Xor Pyramid
  28. Writing Numbers
  29. String Transform
  30. Letter Pair Move Game
  31. Maximum Building I
  32. Sorting Methods
  33. Cyclic Array
  34. List of Sums
  35. Increasing Array II
  36. Food Division
  37. Bit Problem
  38. Swap Round Sorting
  39. Binary Subsequences
  40. Tree Isomorphism I
  41. Counting Sequences
  42. Critical Cities
  43. School Excursion
  44. Coin Grid
  45. Robot Path
  46. Programmers and Artists
  47. Course Schedule II
  48. Removing Digits II
  49. Coin Arrangement
  50. Counting Bishops
  51. Grid Puzzle I
  52. Grid Puzzle II
  53. Empty String
  54. Grid Paths
  55. Bit Substrings
  56. Reversal Sorting
  57. Counting Reorders
  58. Book Shop II
  59. Network Breakdown
  60. Visiting Cities
  61. Missing Coin Sum Queries
  62. Number Grid
  63. Maximum Building II
  64. Filling Trominos
  65. Stick Divisions
  66. Coding Company
  67. Flight Route Requests
  68. Two Stacks Sorting
  69. Tree Isomorphism II
  70. Forbidden Cities
  71. Area of Rectangles
  72. Grid Completion
  73. Creating Offices
  74. Permutations II
  75. Functional Graph Distribution
  76. New Flight Routes
  77. Grid Path Construction