Air Conditioner Installation
Time limit1sMemory limit1024 MB
Given N rooms at distinct integer 3D points, find the minimum number of rooms to mark so every room and every unit-distance corridor between adjacent rooms is covered.
- Level
Medium7 of 10
- Topics
- Graph, Dynamic programming, Tree, Bit manipulation
- Solved
- No attempts yet
Problem
Juhyeon, who runs an air conditioner business, received an inquiry about installing air conditioners in the newly built Newyolla Library. The library gave him the blueprints and asked him to install air conditioners in suitable places. Juhyeon, who had found a chance to make a lot of money after a long time, checked the blueprints with excitement.
The blueprints of Newyolla Library have a unique structure that reflects the library's distinctive architectural philosophy. Rooms exist only at points with integer coordinates in the D blueprint, and between any two rooms whose coordinates are at distance , there is always a corridor or a staircase. The volume of a room is not considered.
Juhyeon, who wanted to sell as many air conditioners as possible, wanted to insist strongly that air conditioners must be installed in every room, but unfortunately the only air conditioners available could cool adjacent rooms. In other words, one air conditioner can cool the room it is installed in, the corridors and staircases connected to that room, and the rooms connected through those corridors and staircases.
Of course, he could deceive the library staff and install air conditioners in every room, but overcharging could cause trouble for his future business, so he wants to sell only the minimum number of air conditioners that can cool every room, corridor, and staircase.
How many air conditioners can Juhyeon sell to the library?
Input
The first line gives the number of rooms in the library, . ()
The next lines give the integer coordinates of each room. (, if )
Output
Print the minimum number of air conditioners Juhyeon can sell.