Inna and Alarm Clock

2024-08-25 08:58
文章标签 inna alarm clock

本文主要是介绍Inna and Alarm Clock,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1105111

相关文章

Angle Between Hands of a Clock

Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand. Answers within 10-5 of the actual value will be accepted as correct. Example 1

【简单题】-CF-390B-Inna, Dima and Song

题目链接:http://codeforces.com/problemset/problem/390/B 题目描述: 两个小盆友弹钢琴,a 数组中的值代表他们分别都能弹到的最高调。如果二者弹出的音调 v1、v2 加起来正好等于 b 数组对应标准音调的话就会增加 v1 * v2 点愉悦值,无法弹出正确音调则愉悦值减一,求愉悦值最大多少? 解题思路: 坑点有二, ①:要用 long long!

翻译_Clock Domain Crossing Design

翻译_Clock Domain Crossing Design 原文标题及连接:Clock Domain Crossing (CDC) Design & Verification Techniques Using SystemVerilog. 作者:Clifford E. Cummings Sunburst Design, Inc. cliffc@sunburst-design.com

NYOJ--484 The Famous Clock

The Famous Clock 时间限制: 1000 ms  |  内存限制: 65535 KB 难度: 1 描述 Mr. B, Mr. G and Mr. M are now in Warsaw, Poland, for the 2012’s ACM-ICPC World Finals Contest. They’ve decided to take a 5 hours tr

【OS】AUTOSAR OS Alarm实现原理

目录 前言 正文 1.OsAlarm配置 1.1 工具配置Alarm 1.1.1. 顶层OsAlarm配置 1.1.2. OsAlarmAction 1.1.3. OsAlarmAutostart 1.2 配置代码分析 1.2.1. Os_JobConfigType 2.OsAlarm实现 3.总结 前言 在《【OS基础】符合AUTOSAR标准的RTAOS-Ala

hdu5387(2015多校8)--Clock(模拟)

题目链接:点击打开链接 题目大意:给出一个时间,问在钟表上这个时间的时候,时针和分针的角度,时针和秒针的角度,分针和秒针的角度,如果不是整数以分数的形式输出。 如果按照最小的格来算,那么: 1s对于秒针来说走1格,分针走12/720格,时针走1/720格。 1m对于分针来说走一个,时针走60/720格。 1h对于时针来说走5格。 计算给出的时间中时针,分针,秒针走的格数,相减得到差,每

android Alarm闹钟发送广播播放音乐

通过网上的例子  自己根据相关功能修改的  如有不合理的地方  请提出来  互相学习 一共有3个类 MainActivity.java 主程序 AlarmReceiver.java 广播接收器 MusicService.java service播放音乐 MainActivity.java package com.yqy.yqy_ala

Android的定时任务Alarm与Timer类的使用

主要使用AlarmManager manager=(AlarmManager)getSystemService(Context。ALARM_SERVICE) 使用manager。set()设置定时任务。 package com.example.servicebestpractice; import android.app.Activity; import android.content.I

【c++】6.延时函数sleep()、usleep()、delay()和计算程序运行时间的函数clock()

延时函数delay(),sleep(),usleep() 推荐使用以下延迟: #include <unistd.h> // 在gcc编译器中,使用的头文件因gcc版本的不同而不同sleep(10); //程序挂起10s usleep(100); //程序挂起100us 可以参考:Linux的sleep()和usleep()的使用和区别: https://blog.csdn.net

Codeforces Round #229 (Div. 2) A. Inna and Alarm Clock

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