# Category Archives: Competitive Programming

## Palindromic Tree | Introduction & Implementation

We encounter various problems like Maximum length palindrome in a string, number of palindromic substrings and many more interesting problems on palindromic substrings . Mostly… Read More »

## Python Input Methods for Competitive Programming

Python is an amazingly user-friendly language with the only flaw of being slow. In comparison to C, C++ and Java, it is quite slower. On… Read More »

## Input/Output from external file in C/C++, Java and Python for Competitive Programming

In Competitive Programming, most of the time we need to enter input for checking our code manually. But it would become cumbersome if we have… Read More »

## Writing C/C++ code efficiently in Competitive programming

First of all you need to know about Template, Macros and Vectors before moving on the next phase! Templates are the foundation of generic programming,… Read More »

## Sqrt (or Square Root) Decomposition | Set 2 (LCA of Tree in O(sqrt(height)) time)

Prerequisite : Introduction and DFS The task is to find LCA of two given nodes in a tree (not necessarily a Binary Tree). In previous… Read More »

## What to do at the time of Wrong Answer (WA)?

There is been always a case that a wrong answer gives too much pain rather than TLE (Time Limit Exceed), as in former you couldn’t… Read More »

## Sqrt (or Square Root) Decomposition Technique | Set 1 (Introduction)

Sqrt (or Square Root) Decomposition Technique is one of the most common query optimization technique used by competitive programmers. This technique helps us to reduce… Read More »

## Graph implementation using STL for competitive programming | Set 2 (Weighted graph)

In Set 1, unweighted graph is discussed. In this post, weighted graph representation using STL is discussed. The implementation is for adjacency list representation of… Read More »

## How to overcome Time Limit Exceed(TLE)?

Many programmers always argue that the problems in Competitive Programming always end up with TLE(Time Limit Exceed). The main problem of this error is that… Read More »

## Graph implementation using STL for competitive programming | Set 1 (DFS of Unweighted and Undirected)

We have introduced Graph basics in Graph and its representations. In this post, a different STL based representation is used that can be helpful to… Read More »

## LCA for general or n-ary trees (Sparse Matrix DP approach )

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »

## Formatted output in Java

Sometimes in Competitive programming, it is essential to print the output in a given specified format. Most users are familiar with printf function in C.… Read More »

## How to prepare for ACM – ICPC?

ACM ICPC(Association for Computing Machinery – International Collegiate Programming Contest) is a world-wide annual multi-tiered programming contest being organized for over thirteen years. The contest… Read More »

## How to prepare for Google Asia Pacific University (APAC) Test ?

Google Asia Pacific University Test, also referred to as Google APAC, is perhaps the best opportunity for a student enrolled in higher education institutes in… Read More »

## Querying the number of distinct colors in a subtree of a colored tree using BIT

Prerequisites : BIT, DFS Given a rooted tree T, with ‘n’ nodes, each node has a color denoted by the array color[](color[i] denotes the color… Read More »