POJ 3620 Avoid The Lakes "Dfs find Unicom block"

Source: Internet
Author: User

Avoid the Lakes
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6826 Accepted: 3637

Description

Farmer John's farm was flooded in the most recent storm, a fact-only aggravated by the information so his cows is death Ly afraid of water. His insurance agency would only repay him, however, a amount depending on the size of the largest "lake" on his farm.

The farm is represented as a rectangular grid with N (1≤ n ≤100) rows andm (1≤m ≤1 XX) columns. Each cell in the grid is either dry or submerged, and exactlyK (1≤kN x M) of the CE LLS is submerged. As one would expect, a lake has a central cell to which and other cells connect by sharing a long edge (not a corner). Any cell this shares a long edge with the central cell or shares a long edge with any connected cell becomes a connected C Ell and is part of the lake.

Input

* Line 1:three space-separated integers: N, M, and K
* Lines 2. K+1:line i+1 describes one submerged location with II space separated integers that is its row and co Lumn:R andC

Output

* Line 1:the number of cells the the largest lake contains.

Sample Input

3 4 53 22 23 12 31 1

Problem description

The farmer John's farm was submerged by a recent storm (flooded), but the truth is still worse (aggravated), because his cow is afraid of water, is dying. However, his insurance company (Insurance Agency) will compensate for the size of the largest pool on his farm.

His farm is visible as a rectangular (rectangular) grid (grid) of n rows (rows) m-Columns (columns). Each cell (cell) is either dry or in water (submerged), and, to be exact, K (1≤kN xM) is wet,

Input

First line: Three separate integers, n,m and K

The second line ... Line k+1: section i+1 behavior Wetland coordinates, HORIZONTAL axis R and ordinate c

Output:

First row: Number of squares of the largest lake

    

POJ 3620 Avoid The Lakes "Dfs find Unicom block"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.