pls correct the time exceeded error in this c++ code.
==== question =====
Rishi is the owner of Mystery Maze. Mystery Maze is a maze of n × n which has m special room bombs.
The maze and its rooms are initially empty. Rishi will cleverly stage and fit the special room bombs one after the other in the maze.
A room in the maze is unreachable if there is at least one room-bomb fitted in the same row or in the same column with this room. Obviously enough, a room is unreachable if the room-bomb is fitted in a particular room.
You are given the rooms of the maze in which Rishi will fit the bombs.
Find the number of rooms for each room-bomb that are reachable after Rishi fits them in the Mystery-maze of rooms.
Input
The first line of the input contains two integers n and m where (1 ≤ m, n ≤ 10^5), and m can’t be greater than either of 10^5 and n^2.
Note: There has to be at least 1 bomb.
All the next m lines contain integers xixi and yiyi (1 ≤ xixi, yiyi ≤ n) — the number of the row and column where the room-bomb can be found. The bombs are fitted in the order in which they appear in the input. It is guaranteed that 2 or more bombs can not co-exist in one place.
Example
input
3 3 1 1 3 1 2 2
output
4 2 0