Problem Solving in Online Judge

This repository contains some frequently used algorithms for competitive programming.

Author: Shafaet Ashraf Shafaet.csedu@gmail.com

BASIC SUBROUTINES

Graph

DFS cycle finding

  • SPOJ Paradox

Max Flow

  • POJ 3204- Ikki's Story I - Road Reconstruction

Min Cost Max Flow

  • UVA 12092 - Paint the Roads

Bipartite Matching(Konigs Theorem)

  • UVA 11419 - Sam i am

Prufer Codes

  • Timus 1069 Prufer Code

Strongly Connected components

  • Topcoder - BikeRiding(SRM 545 div2 level 3)

Bridge

  • UVA 1310 (One way traffic)

Dynamic Programming

Knuth Optimization

  • UVA 10304-Optimal Binary Search Tree
  • ZOJ 2860 Breaking Strings
  • Andrew-Stankevich-10C-Order Preserving Codes

Convex Hull Optimization

  • APIO10-commandos
  • USACO-MAR08-ACQUIRE

LCS Variants

  • Light OJ 1110 - An Easy LCS (Printing Lexicographically Smallest LCS)
  • Light OJ 1157 - LCS Revisited (Number of Unique LCS)

Data Structure

Heavy Light Decomposition

  • Timus 1553 Caves and Tunnels
  • UVA 12424 Answering Queries On A Tree

RMQ using Sparse Table

  • POJ 2019 USACO-Cornfield

Balanced Binary Search Tree(TREAP)

  • SPOJ QMAX3VN

2D Binary Indexed Tree

  • LightOJ 1266 - Points in Rectangle

2D Segment Tree

  • UVA 11297 Census

Lowest Common Ancestor Using Sparse Table*

  • LightOJ 1162 - Min Max Roads

Matrix Exponentiation

  • SPOJ SNAKYNUM
  • LightOJ 1268 - Unlucky String

Geometry

Max Co-linear Points

  • Timus 1052 Rabbit Hunt

Point Segment Distance (3D)

  • LightOJ 1240 - Point Segment Distance (3D)

String Algorithms

KMP

  • LightOJ 1268 - Unlucky String

Gaussian Elimination

Bitwise Gaussian Elimination over gf2

  • UVALIVE 5070 Awkward Lights

Others

Permutation with k non-fixed points

  • LightOJ 1095 - Arrange The Numbers

Prime factorization inside sieve of eratosthenes

  • UVALIVE 4735- Not So Flat After All

Longest Increasing Subsequence in O(nlogk)

  • UVA 11031 - Looking for a Subset

Ternary Search

  • LightOJ 1240 - Point Segment Distance (3D)

2D Grid Compression

  • UVA 11918 - Traveler of Gridland
  • UVA 12069 - Robots inside the Labyrinth