当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Database dictionary Navicat automatic generation version
KS009基于SSH实现宠物管理系统
JSP webshell免杀——webshell免杀
UVM learning - object attribute of UVM phase
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
《MySQL 8 DBA基础教程》简介
对话吴纲:我为什么笃信“大国品牌”的崛起?
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
"Matching" is true love, a new attitude for young people to make friends
js数组常用方法
随机推荐
Leetcode+ 76 - 80 storm search topic
[Lua] summary of common knowledge points (including common interview sites)
VSCode工具使用
[SUCTF2018]followme
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Stm32 et développement de moteurs (système supérieur)
PCL 点云转深度图像
(五)APA场景搭建之挡位控制设置
MYSQL环境配置
Sus system availability scale
MySQL lethal serial question 4 -- are you familiar with MySQL logs?
Operator-1初识Operator
12. Process synchronization and semaphore
The URL in the RTSP setup header of the axis device cannot take a parameter
UVM learning - object attribute of UVM phase
转换YV12到RGB565图像转换,附YUV转RGB测试
Flink calculates topn hot list in real time
Use WinDbg to statically analyze dump files (summary of practical experience)
Oracle 笔记
Solution of mysql8 forgetting password file in Windows Environment