hdu1234

来源:互联网 发布:一键救砖刷机软件 编辑:程序博客网 时间:2024/06/06 03:58

开门人和关门人

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10846    Accepted Submission(s): 5522
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234

Problem Description
每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。现有一堆杂乱的机房签
到、签离记录,请根据记录找出当天开门和关门的人。
 

Input
测试输入的第一行给出记录的总天数N ( > 0 )。下面列出了N天的记录。
每天的记录在第一行给出记录的条目数M ( > 0 ),下面是M行,每行的格式为

证件号码 签到时间 签离时间

其中时间按“小时:分钟:秒钟”(各占2位)给出,证件号码是长度不超过15的字符串。
 

Output
对每一天的记录输出1行,即当天开门和关门人的证件号码,中间用1空格分隔。
注意:在裁判的标准测试输入中,所有记录保证完整,每个人的签到时间在签离时间之前,
且没有多人同时签到或者签离的情况。
 

Sample Input
31ME3021112225321 00:00:00 23:59:592EE301218 08:05:35 20:56:35MA301134 12:35:45 21:40:423CS301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40
 

Sample Output
ME3021112225321 ME3021112225321EE301218 MA301134SC3021234 CS301133
解题思路:
考察string的应用。两次排序。
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;struct node{    string a , s , e;}q[1001];string start , endd;bool cmp1(node a , node b){    return a.s < b.s;}bool cmp2(node a , node b){    return a.e > b.e;}int main(){    #ifdef DoubleQ    freopen("in.txt","r",stdin);    #endif    int T;    scanf("%d",&T);    while(T--)    {        int n;        scanf("%d",&n);        for(int i = 0; i < n ; i ++)            cin >> q[i].a >> q[i].s >> q[i].e;        sort(q , q + n , cmp1);        start = q[0].a;        sort(q , q + n , cmp2);        endd = q[0].a;        cout << start << " " << endd << endl;    }}


0 0
原创粉丝点击