A9294 | Inna and Alarm Clock
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Inna loves sleeping very much, so she needs $n$ alarm clocks in total to wake up. Let's suppose that Inna's room is a $100×100$ square with the lower left corner at point $(0,0)$ and with the upper right corner at point $(100,100)$ . Then the alarm clocks are points with integer coordinates in this square.
The morning has come. All $n$ alarm clocks in Inna's room are ringing, so Inna wants to turn them off. For that Inna has come up with an amusing game:
- First Inna chooses a type of segments that she will use throughout the game. The segments can be either vertical or horizontal.
- Then Inna makes multiple moves. In a single move, Inna can paint a segment of any length on the plane, she chooses its type at the beginning of the game (either vertical or horizontal), then all alarm clocks that are on this segment switch off. The game ends when all the alarm clocks are switched off.
Inna is very sleepy, so she wants to get through the alarm clocks as soon as possible. Help her, find the minimum number of moves in the game that she needs to turn off all the alarm clocks!
The morning has come. All $n$ alarm clocks in Inna's room are ringing, so Inna wants to turn them off. For that Inna has come up with an amusing game:
- First Inna chooses a type of segments that she will use throughout the game. The segments can be either vertical or horizontal.
- Then Inna makes multiple moves. In a single move, Inna can paint a segment of any length on the plane, she chooses its type at the beginning of the game (either vertical or horizontal), then all alarm clocks that are on this segment switch off. The game ends when all the alarm clocks are switched off.
Inna is very sleepy, so she wants to get through the alarm clocks as soon as possible. Help her, find the minimum number of moves in the game that she needs to turn off all the alarm clocks!
输入格式
The first line of the input contains integer $n$ $(1<=n<=10^{5})$ — the number of the alarm clocks. The next $n$ lines describe the clocks: the $i$ -th line contains two integers $x_{i}$ , $y_{i}$ — the coordinates of the $i$ -th alarm clock $(0<=x_{i},y_{i}<=100)$ .
Note that a single point in the room can contain any number of alarm clocks and the alarm clocks can lie on the sides of the square that represents the room.
Note that a single point in the room can contain any number of alarm clocks and the alarm clocks can lie on the sides of the square that represents the room.
输出格式
In a single line print a single integer — the minimum number of segments Inna will have to draw if she acts optimally.
输入输出样例
输入 #1
4 0 0 0 1 0 2 1 0
输出 #1
2
输入 #2
4 0 0 0 1 1 0 1 1
输出 #2
2
输入 #3
4 1 1 1 2 2 3 3 3
输出 #3
3
In the first sample, Inna first chooses type "vertical segments", and then she makes segments with ends at : $(0,0)$ , $(0,2)$ ; and, for example, $(1,0)$ , $(1,1)$ . If she paints horizontal segments, she will need at least 3 segments.
In the third sample it is important to note that Inna doesn't have the right to change the type of the segments during the game. That's why she will need 3 horizontal or 3 vertical segments to end the game.
In the third sample it is important to note that Inna doesn't have the right to change the type of the segments during the game. That's why she will need 3 horizontal or 3 vertical segments to end the game.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted