Inna and Alarm Clock

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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!

Input

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

Output

In a single line print a single integer — the minimum number of segments Inna will have to draw if she acts optimally.

Sample test(s)
input
4
0 0
0 1
0 2
1 0

output
2

input
4
0 0
0 1
1 0
1 1

output
2

input
4
1 1
1 2
2 3
3 3

output
3

Note

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相关推荐

  1. 《101 Windows Phone 7 Apps》读书笔记-ALARM CLOCK

    课程内容 Ø 隔离存储空间 Ø 设置 Ø 设置页面向导 Ø Toggle Switch控件 Ø 使用自定义字体 Alarm Clock模仿的是一种有点复古的数字闹钟.它具有固定的显示,上面的分段可以根 ...

  2. 社区奖品之Alarm Clock逃跑闹钟

      Alarm Clock逃跑闹钟 特点: 1.闹钟会一直朝前跑,请放在床头柜朝外的角落里: 2.闹钟能从3英尺高的床头柜上掉下来,所以不要放的太高.柜子最好不要超过3英尺: 3.闹钟能在木地板和多数 ...

  3. 计算机闹铃音乐在线听,电脑闹钟提醒(Free Alarm Clock)

    用于计算机的闹钟工具,还可以方便的提醒您的日程安排.使用完全免费滴.日程和闹钟分为平日和节假日,区别设定,每天也可以单独设定.闹钟独有的"赖床"功能,绝对值得您一试... 特点: ...

  4. Codeforces Round #229

    390 A. Inna and Alarm Clock http://codeforces.com/contest/390/problem/A 水题一枚,两个set就可完成 1 #include< ...

  5. alarm/pause

    最近做了个终端I/O的问题,一个简单的东西是做出来了,可是并不怎么理解,发现APUE上刚好有,那么就暂且放一放,等以后弄明白了,再写 因为进程间通信的消息队列和信号量的问题看得不明白,并且看得激情也不 ...

  6. Android4.4之后休眠状态下Alarm不准时的问题

    Android4.4及之后休眠状态下Alarm不准时的问题 为了减轻功耗,延长电池使用时间,Android 4.4及之后的版本采用非精准闹钟机制,以及休眠状态下的wakeup类型的alarm不会实时唤 ...

  7. Android7.0 Doze模式分析(三)alarm

    上篇博客分析了Doze模式下WakeLock,这篇我们分析Alarm. 白名单 首先我们从白名单开始,在DeviceIdleController中会设置alarm的白名单. public final ...

  8. alarm()闹钟函数

    #include #include #include #include int main(void) { int ret = alarm(5); printf("第一次调用返回值:%d\n& ...

  9. android alarm 的权限,android - Android权限被拒绝-com.android.alarm.permission.SET_ALARM - 堆栈内存溢出...

    我正在尝试通过我的应用设置闹钟,但是当我通过执行以下操作启动意图时,如下所述: 如何在Android中使用意图启动闹钟屏幕? public boolean onMenuItemSelected(int ...

  10. linux内核alarm,linux中alarm函数的实例讲解

    linux alarm函数简介 上代码: #include #include #include #include int main(int argc, char *argv[]) { alarm(5) ...

最新文章

  1. 李志飞:想在中国复制 Echo 的成功,肯定都不靠谱
  2. Webservice入门教程_用CXF编写基于Spring的WebService
  3. Java FilterInputStream reset()方法与示例
  4. Windows xp LoadPerf系统错误
  5. 安装服务时出现The system cannot execute the specified program
  6. python反向代理服务器_主机、服务器,代理服务器,反向代理服务器理解(自用)...
  7. 各版SQL字符串拼接
  8. JavaScript Cookie
  9. *-mapper.xml配置文件
  10. Tomcat系列(4)——Tomcat 组件及架构详细部分
  11. [导入]你的网站被订阅了吗(浅谈RSS2.0)续
  12. 部分相机和相机镜头的参数
  13. MVX-Net | 多模型三位像素网络用于3D目标检测
  14. Android中的短信收不到问题,华为的安卓(Android)系统手机收不到短信问题解决方法...
  15. iOS视频播放的基本方法
  16. Austroads交通管理指南 2022(英)(附下载)
  17. 一台计算机组装完成以后,要先装什么.,一台刚组装好的电脑,还需要进行哪些操作?...
  18. 混合波束成形| 宽带系统基于码本的信道估计 《Channel Estimation for Hybrid Architecture-Based Wideband Millimete
  19. Oracle ltrim() rtrim() 函数详细用法
  20. 利用Java Calendar类打印日历

热门文章

  1. 读书笔记:移动的帝国_日本移动互联网兴衰启示录
  2. 2019 年第 34 周 DApp 影响力排行榜 | TokenInsight
  3. 使用CM快速搭建CDH集群
  4. 记录office安装一半重启后无法继续安装
  5. SQL语句进阶学习一(where、通配符、正则表达式、计算字段、数据处理函数、分组数据)
  6. 阿里巴巴管理三板斧 - 阿里巴巴专栏
  7. iOS系统语音播报文字
  8. 计算机网络总线型结构优 缺点,总线型拓扑结构优缺点是什么
  9. Spring 全家桶,永远滴神
  10. 用html制作课程表