Inna and Alarm Clock
Inna and Alarm Clock
1 second
256 megabytes
standard input
standard output
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 first line of the input contains integer n (1 ≤ n ≤ 105) — the number of the alarm clocks. The next n lines describe the clocks: the i-th line contains two integers xi, yi — the coordinates of the i-th alarm clock (0 ≤ xi, yi ≤ 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.
In a single line print a single integer — the minimum number of segments Inna will have to draw if she acts optimally.
4 0 0 0 1 0 2 1 0
2
4 0 0 0 1 1 0 1 1
2
4 1 1 1 2 2 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.
#include <stdio.h>int main()
{int n,i,j,num1,num2;int a[109][109] = {0};scanf("%d",&n);for(i = 0; i<n; i++){int x,y;scanf("%d %d",&x,&y);a[x][y] = 1;}num1 = 0;num2 = 0;for(i = 0; i<=100; i++){for(j = 0; j<=100; j++){if(a[i][j] == 1){num1++;break;}}}for(i = 0; i<=100; i++){for(j = 0; j<=100; j++){if(a[j][i] == 1){num2++;break;}}}if(num1 > num2)printf("%d\n",num2);elseprintf("%d\n",num1);return 0;
}
Inna and Alarm Clock相关推荐
- 《101 Windows Phone 7 Apps》读书笔记-ALARM CLOCK
课程内容 Ø 隔离存储空间 Ø 设置 Ø 设置页面向导 Ø Toggle Switch控件 Ø 使用自定义字体 Alarm Clock模仿的是一种有点复古的数字闹钟.它具有固定的显示,上面的分段可以根 ...
- 社区奖品之Alarm Clock逃跑闹钟
Alarm Clock逃跑闹钟 特点: 1.闹钟会一直朝前跑,请放在床头柜朝外的角落里: 2.闹钟能从3英尺高的床头柜上掉下来,所以不要放的太高.柜子最好不要超过3英尺: 3.闹钟能在木地板和多数 ...
- 计算机闹铃音乐在线听,电脑闹钟提醒(Free Alarm Clock)
用于计算机的闹钟工具,还可以方便的提醒您的日程安排.使用完全免费滴.日程和闹钟分为平日和节假日,区别设定,每天也可以单独设定.闹钟独有的"赖床"功能,绝对值得您一试... 特点: ...
- Codeforces Round #229
390 A. Inna and Alarm Clock http://codeforces.com/contest/390/problem/A 水题一枚,两个set就可完成 1 #include< ...
- alarm/pause
最近做了个终端I/O的问题,一个简单的东西是做出来了,可是并不怎么理解,发现APUE上刚好有,那么就暂且放一放,等以后弄明白了,再写 因为进程间通信的消息队列和信号量的问题看得不明白,并且看得激情也不 ...
- Android4.4之后休眠状态下Alarm不准时的问题
Android4.4及之后休眠状态下Alarm不准时的问题 为了减轻功耗,延长电池使用时间,Android 4.4及之后的版本采用非精准闹钟机制,以及休眠状态下的wakeup类型的alarm不会实时唤 ...
- Android7.0 Doze模式分析(三)alarm
上篇博客分析了Doze模式下WakeLock,这篇我们分析Alarm. 白名单 首先我们从白名单开始,在DeviceIdleController中会设置alarm的白名单. public final ...
- alarm()闹钟函数
#include #include #include #include int main(void) { int ret = alarm(5); printf("第一次调用返回值:%d\n& ...
- android alarm 的权限,android - Android权限被拒绝-com.android.alarm.permission.SET_ALARM - 堆栈内存溢出...
我正在尝试通过我的应用设置闹钟,但是当我通过执行以下操作启动意图时,如下所述: 如何在Android中使用意图启动闹钟屏幕? public boolean onMenuItemSelected(int ...
- linux内核alarm,linux中alarm函数的实例讲解
linux alarm函数简介 上代码: #include #include #include #include int main(int argc, char *argv[]) { alarm(5) ...
最新文章
- 李志飞:想在中国复制 Echo 的成功,肯定都不靠谱
- Webservice入门教程_用CXF编写基于Spring的WebService
- Java FilterInputStream reset()方法与示例
- Windows xp LoadPerf系统错误
- 安装服务时出现The system cannot execute the specified program
- python反向代理服务器_主机、服务器,代理服务器,反向代理服务器理解(自用)...
- 各版SQL字符串拼接
- JavaScript Cookie
- *-mapper.xml配置文件
- Tomcat系列(4)——Tomcat 组件及架构详细部分
- [导入]你的网站被订阅了吗(浅谈RSS2.0)续
- 部分相机和相机镜头的参数
- MVX-Net | 多模型三位像素网络用于3D目标检测
- Android中的短信收不到问题,华为的安卓(Android)系统手机收不到短信问题解决方法...
- iOS视频播放的基本方法
- Austroads交通管理指南 2022(英)(附下载)
- 一台计算机组装完成以后,要先装什么.,一台刚组装好的电脑,还需要进行哪些操作?...
- 混合波束成形| 宽带系统基于码本的信道估计 《Channel Estimation for Hybrid Architecture-Based Wideband Millimete
- Oracle ltrim() rtrim() 函数详细用法
- 利用Java Calendar类打印日历