ICPC 2014 - I. Sensor Network
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/2014/I-sensor-network. Edit
competitive_programming/icpc/2014/I-sensor-network/solution.tex to update the written solution and
competitive_programming/icpc/2014/I-sensor-network/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.
Problem I
Sensor Network
Time Limit: 2 seconds
A wireless sensor network consists of au-
tonomous sensors scattered in an environment
where they monitor conditions such as temper-
ature, sound, and pressure.
Samantha is a researcher working on the
Amazon Carbon-dioxide Measurement (ACM)
project. In this project, a wireless sensor net-
work in the Amazon rainforest gathers envi-
Picture from Wikimedia Commons
ronmental information. The Amazon rainfor-
est stores an amount of carbon equivalent to a
decade of global fossil fuel emissions, and it plays a crucial role in the world’s oxygen-transfer pro-
cesses. Because of the huge size of this forest, changes in the forest affect not only the local environment
but also global climate by altering wind and ocean current patterns. The goal of the ACM project is to
help scientists better understand earth’s complex ecosystems and the impact of human activities.
Samantha has an important hypothesis and to test her hypothesis, she needs to find a subset of sensors
in which each pair of sensors can communicate directly with each other. A sensor can communicate
directly with any other sensor having distance at most d from it. In order for her experiments to be as
accurate as possible, Samantha wants to choose as many sensors as possible.
As one does not simply walk into the Amazon, Samantha cannot add new sensors or move those that
are currently in place. So given the current locations of the sensors, she needs your help to find the
largest subset satisfying her criteria. For simplicity, represent the location of each sensor as a point in a
two-dimensional plane with the distance between two points being the usual Euclidean distance.
Input
The input consists of a single test case. The first line contains two integers n and d (1 ≤ n ≤ 100 and
1 ≤ d ≤ 10 000), where n is the number of sensors available and d is the maximum distance between
sensors that can communicate directly. Sensors are numbered 1 to n. Each of the next n lines contains
two integers x and y (−10 000 ≤ x, y ≤ 10 000) indicating the sensor coordinates, starting with the first
sensor.
Output
Display a maximum subset of sensors in which each pair of sensors can communicate directly. The
first line of output should be the size of the subset. The second line of output should be the (one-
based) indices of the sensors in the subset. If there are multiple such subsets, any one of them will be
accepted.
Sample Input 1 Sample Output 1
4 1 2
0 0 1 2
0 1
1 0
1 1
Sample Input 2 Sample Output 2
5 20 3
0 0 4 3 5
0 2
100 100
100 110
100 120
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 2014\\I. Sensor Network Time Limit: 2 seconds A wireless sensor network consists of autonomous sensors scattered in an environment}
\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;
}