# Category Archives: Competitive Programming

## What to do at the time of Wrong Answer (WA)?February 3, 2017

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)January 30, 2017

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)January 20, 2017

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)January 19, 2017

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 < O(nlogn), O(logn)>)

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 JavaOctober 16, 2016

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?October 4, 2016

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 ?September 5, 2016

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 BITJuly 24, 2016

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 »

## Test Case Generation | Set 5 (Generating random Sorted Arrays and Palindromes)July 15, 2016

Generating Random Sorted Arrays We store the random array elements in an array and then sort it and print it.   Generating Random Palindromes The… Read More »

## Test Case Generation | Set 4 (Random directed / undirected weighted and unweighted Graphs)July 14, 2016

Generating Random Directed Unweighted Graphs Since this is a graph, the test data generation plan doesn’t guarantee that a cycle gets formed or not. The… Read More »

## Test Case Generation | Set 3 (Unweighted and Weighted Trees)July 10, 2016

Generating Random Unweighted Trees Since this is a tree,  the test data generation plan is such that no cycle gets formed. The number of edges… Read More »