A. Airport Construction
event sponsor ICPC 2017 Problem A Airport Construction Time limit: 2 seconds The tropical island nation of Piconesia is famous for its beautiful beaches, lush vegetation, cocoa and coffee plantations, and wonderful weather all year round. This paradise is b...
Problem Statement
Formatted from the contest statement text, with sample tests broken out into copyable blocks.
The tropical island nation of Piconesia is famous for its beautiful beaches, lush vegetation, cocoa and coffee plantations, and wonderful weather all year round. This paradise is being considered as a future location for the World Finals of the ACM International Collegiate Programming Contest (or at the very least a vacation spot for the executive council). There is only one small problem: the island is really hard to reach. Currently, the fastest way to reach the island takes three days from the nearest airport, and uses a combination of fishing boat, oil tanker, kayak, and submarine. To make attending the ICPC World Finals slightly easier and to jump-start the island’s tourism business, Piconesia is planning to build its first airport. Since longer landing strips can accommodate larger airplanes, Piconesia has decided to build the longest possible landing strip on their island. Unfortunately, they have been unable to determine where this landing strip should be located. Maybe you can help? For this problem we model the boundary of Piconesia as a polygon. Given this polygon, you need to compute the length of the longest landing strip (i.e., straight line segment) that can be built on the island. The landing strip must not intersect the sea, but it may touch or run along the boundary of the island. Figure A.1 shows an example corresponding to the first sample input.
Figure A.1: The island modeled as a polygon. The longest possible landing strip is shown as a thick line.
Input
The input starts with a line containing an integer n (3 ≤ n ≤ 200) specifying the number of vertices of the polygon. This is followed by n lines, each containing two integers x and y (|x|, |y| ≤ 106 ) that give the coordinates (x, y) of the vertices of the polygon in counter-clockwise order. The polygon is simple, i.e., its vertices are distinct and no two edges of the polygon intersect or touch, except that consecutive edges touch at their common vertex. In addition, no two consecutive edges are collinear.
Rapid City
sponsor
ICPC 2017Output
Display the length of the longest straight line segment that fits inside the polygon, with an absolute or relative error of at most 10−6 .
Sample Tests
7
0 20
40 0
40 20
70 50
50 70
30 50
0 50 76.157731059 3
0 2017
-2017 -2017
2017 0 4510.149110617 Editorial
The solution write-up is rendered from the LaTeX source, with equations kept live through MathJax.
Key Observations
Write the structural observations that make the problem tractable.
State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
If the constraints matter, explain exactly which part of the solution they enable.
Algorithm
Describe the data structures and the state maintained by the algorithm.
Explain the processing order and why it is sufficient.
Mention corner cases explicitly if they affect the implementation.
Correctness Proof
We prove that the algorithm returns the correct answer.
Lemma 1.
State the first key claim.
Proof.
Provide a concise proof.
Lemma 2.
State the next claim if needed.
Proof.
Provide a concise proof.
Theorem.
The algorithm outputs the correct answer for every valid input.
Proof.
Combine the lemmas and finish the argument.
Complexity Analysis
State the running time and memory usage in terms of the input size.
Implementation Notes
Mention any non-obvious implementation detail that is easy to get wrong.
Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
Code
C++ solution used for this page.
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Source Files and Assets
Raw files are still available here when you want the original TeX, C++, or statement assets.
Show raw files
competitive_programming/icpc/2017/A-airport-construction/solution.texC++ implementationcompetitive_programming/icpc/2017/A-airport-construction/solution.cppStatement textcompetitive_programming/icpc/2017/A-airport-construction/statement.txtStatement PDFcompetitive_programming/icpc/2017/A-airport-construction/statement.pdfMetadatacompetitive_programming/icpc/2017/A-airport-construction/meta.jsonYear packetcompetitive_programming/icpc/2017/contest_problems.pdf