ICPC 2014
ICPC 2014

I. Sensor Network

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...

Updated May 21, 2026
Track ICPC
Year 2014
Statement Text + PDF
TeXC++Statement textStatement PDF

Problem Statement

Formatted from the contest statement text, with sample tests broken out into copyable blocks.

Time limit 2 seconds
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 Tests

Sample 1
Sample Input
4   1
0   0
0   1
1   0
1   1
Sample Output
2
1 2
Sample 2
Sample Input
5 20
0 0
0 2
100 100
100 110
100 120
Sample Output
3
4 3 5

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

  1. Describe the data structures and the state maintained by the algorithm.

  2. Explain the processing order and why it is sufficient.

  3. 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.

C++

Clean code view with a raw-file link when you want the original source.

Raw file
#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