D-query :spoj (MO) (for only queries in range )
http://www.spoj.com/problems/DQUERY/en/ DQUERY - D-query In this question , the concept of rearranging queries is used , the method known as "MO". In the question, it is asked to find total different numbers present in the range [l,r] . "add" and "del" functions are written accordingly. #include<bits/stdc++.h> using namespace std; int readInt () { bool minus = false; int result = 0; char ch; ch = getchar(); while (true) { if (ch == '-') break; if (ch >= '0' && ch <= '9') break; ch = getchar(); } if (ch == '-') minus = true; else result = ch-'0'; while (true) { ch = getchar(); if...