TopcoderArchive
Archive
Algorithm problem

FortConstruction

Problem statement, definition, constraints, and public examples.

Problem Statement

In medieval times, it was especially important to build military encampments at strategic locations. One such type of location is any site completely surrounded by rivers, since such a site is much easier to defend. It was also preferable that the site be as large as possible, so that it can accomodate more inhabitants.

For simplicity, we will model the land as a plane and rivers as lines. Given a list of rivers, return a double, the area of the largest site completely surrounded by rivers. The rivers will be given as a String[], where each element is formatted as "x1 y1 x2 y2" (quotes for clarity), the coordinates of two points representing the river.

If there is no suitable site, return 0.

Definition

Class:
FortConstruction
Method:
largestSite
Parameters:
String[]
Returns:
double
Method signature:
double largestSite(String[] rivers)
(be sure your method is public)

Constraints

  • rivers will contain between 1 and 50 elements, inclusive.
  • Each element of rivers will be at most 50 characters long.
  • Each element of rivers will be formatted as "x1 y1 x2 y2" (without the quotes).
  • No two elements of rivers will represent the same river.
  • All of the coordinates will be between -100 and 100, inclusive.

Examples

    No public sample cases were explicitly marked for this problem in the original data.

    Back to all problems