ICPC 2013 - G. Map Tiles
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
Source-first archive entry
This page is built from the copied files in competitive_programming/icpc/2013/G-map-tiles. Edit
competitive_programming/icpc/2013/G-map-tiles/solution.tex to update the written solution and
competitive_programming/icpc/2013/G-map-tiles/solution.cpp to update the implementation.
The website does not replace those files with hand-maintained HTML. It reads the copied source tree during the build and exposes the exact files below.
Problem Statement
Copied statement text kept beside the solution archive for direct reference.
ICPC 2013
2013 World Finals
St. Petersburg
HOSTED BY ITMO
Problem G
Map Tiles
Time Limit: 20 seconds
Publishing maps is not an easy task. First you need some appropriate transformation to display the
earth’s spherical shape in a two-dimensional plane. Then another issue arises – most high-quality maps
are too large to be printed on a single page of paper. To cope with that, map publishers often split maps
into several rectangular tiles, and print each tile on one page. In this problem, you will examine this
“tiling” process.
The International Cartographic Publishing Company (ICPC) needs to cut their printing costs by mini-
mizing the number of tiles used for their maps. Even with a fixed tile size (determined by the page size)
and map scale, you can still optimize the situation by adjusting the tile grid.
The left side of Figure G.1 shows 14 map tiles covering a region. The right side shows how you can
cover the same region with only 10 tiles, without changing the tile sizes or orientation.
Figure G.1: Two possible ways of tiling Texas.
Your task is to help the ICPC find the minimum number of tiles needed to cover a given region. For
simplicity, the region will be given as a closed polygon that does not intersect itself.
Note that the tiles must be part of a rectangular grid aligned with the x-axis and y-axis. That is, they
touch each other only with their whole sides and cannot be rotated. Also note that although all input
coordinates are integers, tiles may be located at non-integer coordinates.
The polygon may touch the edges of marginal lines (as in Sample Input 2). However, to avoid floating-
point issues, you may assume the optimal answer will not change even if the polygon is allowed to go
outside the map tiles by a distance of 10−6 .
Input
The input consists of a single test case. The first line of a test case contains three integers: n, xs , and ys .
The number of polygon vertices is n (3 ≤ n ≤ 50), and xs and ys (1 ≤ xs , ys ≤ 100) are the dimensions
of each tile. Each of the next n lines contains two integers x and y (0 ≤ x ≤ 10xs , 0 ≤ y ≤ 10ys ),
specifying the vertices of the polygon representing the region (in either clockwise or counter-clockwise
order).
ICPC 2013
2013 World Finals
St. Petersburg
HOSTED BY ITMO
Output
Display the minimal number of tiles necessary to cover the whole interior of the polygon.
Sample Input 1 Sample Output 1
12 9 9 10
1 8
1 16
6 16
9 29
19 31
23 24
30 23
29 18
20 12
22 8
14 0
14 8
Sample Input 2 Sample Output 2
4 5 7 1
10 10
15 10
15 17
10 17
Editorial
Rendered from the copied solution.tex file. The original TeX source remains
available below.
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
Exact copied C++ implementation from solution.cpp.
#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
Exact copied source-of-truth files. Edit solution.tex for the write-up and solution.cpp for the implementation.
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{enumitem}
\title{ICPC World Finals 2013\\G. Map Tiles Time Limit: 20 seconds}
\author{}
\date{}
\begin{document}
\maketitle
\section*{Problem Summary}
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
\section*{Key Observations}
\begin{itemize}[leftmargin=*]
\item Write the structural observations that make the problem tractable.
\item State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
\item If the constraints matter, explain exactly which part of the solution they enable.
\end{itemize}
\section*{Algorithm}
\begin{enumerate}[leftmargin=*]
\item Describe the data structures and the state maintained by the algorithm.
\item Explain the processing order and why it is sufficient.
\item Mention corner cases explicitly if they affect the implementation.
\end{enumerate}
\section*{Correctness Proof}
We prove that the algorithm returns the correct answer.
\paragraph{Lemma 1.}
State the first key claim.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Lemma 2.}
State the next claim if needed.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Theorem.}
The algorithm outputs the correct answer for every valid input.
\paragraph{Proof.}
Combine the lemmas and finish the argument.
\section*{Complexity Analysis}
State the running time and memory usage in terms of the input size.
\section*{Implementation Notes}
\begin{itemize}[leftmargin=*]
\item Mention any non-obvious implementation detail that is easy to get wrong.
\item Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
\end{itemize}
\end{document}
#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;
}