当前位置:网站首页>Hdu1234 door opener and door closer (water question)
Hdu1234 door opener and door closer (water question)
2022-07-02 10:55:00 【Woodenman Du】
Topic link http://acm.hdu.edu.cn/showproblem.php?pid=1234
Question
Problem Description
The first person to the computer room every day should open the door , The last person to leave is to close the door . There are a lot of messy machine room signs
To 、 Check out record , Please find out who opened and closed the door according to the record .
Input
The first line of the test input gives the total number of days recorded N ( > 0 ). The following is listed N A record of days .
The daily record gives the number of entries in the first line M ( > 0 ), Here is M That's ok , The format of each line is :
ID number Check in time Check out time
The time is according to “ Hours : minute : Second ”( Each account 2 position ) give , The ID number is no longer than 15 String .
Output
Output the record of each day 1 That's ok , That is, the ID number of the person who opened and closed the door that day , Intermediate use 1 The blank space to separate .
Be careful :
In the referee's standard test input , All records shall be complete , Everyone's check-in time is before the check-out time ,
And there is no situation that many people sign in or sign out at the same time .

Solve
Find the smallest and largest in a pile of time , Just pay attention to format control
AC Code
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int t, n;
int main(void)
{
scanf("%d", &t);
while(t--){
scanf("%d", &n);
string en, st; // Starting and ending Certificate No
int t_en = -1, t_st = 1e9; // Starting and ending time
int h1, h2, m1, m2, s1, s2;
for(int i = 1; i <= n; i++){
string s; cin >>s;
// Read in time
scanf("%02d:%02d:%02d", &h1, &m1, &s1);
scanf("%02d:%02d:%02d", &h2, &m2, &s2);
// Calculation
int t1 = h1 * 3600 + m1 * 60 + s1;
int t2 = h2 * 3600 + m2 * 60 + s2;
// Compare
if(t1 < t_st) { st = s; t_st = t1; }
if(t2 > t_en) { en = s; t_en = t2; }
}
cout <<st <<" " <<en <<endl;
}
return 0;
}边栏推荐
- Oracle 笔记
- flink 提交程序
- Is this code PHP MySQL redundant?
- 618再次霸榜的秘密何在?耐克最新财报给出答案
- js setTimeout()与面试题
- What are the popular frameworks for swoole in 2022?
- 点云投影图片
- 07 data import sqoop
- Dialogue Wu Gang: why do I believe in the rise of "big country brands"?
- Use WinDbg to statically analyze dump files (summary of practical experience)
猜你喜欢

从.bag文件中读取并保存.jpg图片和.pcd点云

Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer

Retrofit's callback hell is really vulnerable in kotlin synergy mode!

Win11 arm系统配置.net core环境变量

Rapid prototyping

Shapiro Wilk normal analysis by SPSS

Flink calculates topn hot list in real time

MySQL数据库远程访问权限设置

SPSS做Shapiro-Wilk正态分析

MYSQL环境配置
随机推荐
Mongodb quickly get started with some simple operations of mongodb command line
4.随机变量
MongoDB-快速上手MongoDB命令行的一些简单操作
首份中国企业敏捷实践白皮书发布| 附完整下载
记录 AttributeError: ‘NoneType‘ object has no attribute ‘nextcall‘
14.信号量的代码实现
sqoop的表的导入
JSP webshell免殺——JSP的基礎
Redis set password
全网显示 IP 归属地,是怎么实现的?
618再次霸榜的秘密何在?耐克最新财报给出答案
JS settimeout() and interview questions
数据库字典Navicat自动生成版本
lunix重新分配root 和 home 空间内存
01-spooldir
sqoop创建job出现的一系列问题解决方法
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
"Matching" is true love, a new attitude for young people to make friends
VSCode工具使用
UVM - usage of common TLM port