{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 \u0026lt;\u003d N \u0026lt;\u003d 500). The grid contains K asteroids (1 \u0026lt;\u003d K \u0026lt;\u003d 10,000), which are conveniently located at the lattice points of the grid.\r\u003cbr\u003e\r\u003cbr\u003eFortunately, Bessie has a powerful weapon that can vaporize all the asteroids in any given row or column of the grid with a single shot.This weapon is quite expensive, so she wishes to use it sparingly.Given the location of all the asteroids in the field, find the minimum number of shots Bessie needs to fire to eliminate all of the asteroids."}},{"title":"Input","value":{"format":"HTML","content":"* Line 1: Two integers N and K, separated by a single space.\r\u003cbr\u003e* Lines 2..K+1: Each line contains two space-separated integers R and C (1 \u0026lt;\u003d R, C \u0026lt;\u003d N) denoting the row and column coordinates of an asteroid, respectively."}},{"title":"Output","value":{"format":"HTML","content":"* Line 1: The integer representing the minimum number of times Bessie must shoot."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 4\r\n1 1\r\n1 3\r\n2 2\r\n3 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"INPUT DETAILS:\r\u003cbr\u003eThe following diagram represents the data, where \"X\" is an asteroid and \".\" is empty space:\r\u003cbr\u003e\u003ctt\u003eX.X\r\u003cbr\u003e.X.\r\u003cbr\u003e.X.\u003c/tt\u003e\r\u003cbr\u003e\r\u003cbr\u003eOUTPUT DETAILS:\r\u003cbr\u003eBessie may fire across row 1 to destroy the asteroids at (1,1) and (1,3), and then she may fire down column 2 to destroy the asteroids at (2,2) and (3,2)."}}]}