hdu 开门人和关门人

/*
* hdu OpenDoorManAndCloseDoorMan
* date 2014/5/13
* state AC
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

struct DoorMan
{
    char name[20];
    int startH,startM,startS;
    int endH,endM,endS;
};

vector<DoorMan> vectorDoorMan;

bool CompStartTime(const DoorMan& a,const DoorMan& b)
{
    if(a.startH!=b.startH)return a.startH<b.startH;
    else if(a.startH == b.startH && a.startM!=b.startM)
    {
        return a.startM<b.startM;
    }
    else if(a.startH == b.startH && a.startM == b.startM && a.startS !=b.startS)
        return a.startS<b.startS;
}

bool CompEndTime(const DoorMan& a,const DoorMan& b)
{
    /*
    if(a.endH!=b.endH)return a.endH>b.endH;
    else if(a.endH==b.endH && a.endM!=b.endM)
        return a.endM>b.endM;
    else if(a.endH==b.endH && a.endM==b.endM && a.endS!=b.endS)
        return a.endS>b.endS;
    */
    if(a.endH!=b.endH)return a.endH>b.endH;
    else if(a.endM!=b.endM) return a.endM>b.endM;
    else if(a.endS!=b.endS) return a.endS>b.endS;
}

int main()
{
    //cout << "Hello world!" << endl;
    freopen("input.txt","r",stdin);
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        vectorDoorMan.clear();
        int M;
        cin>>M;
        for(int j=0;j<M;j++)
        {
            //char strName[20];
            //int startH,startM,startS;
            //int endH,endM,endS;
            DoorMan doorMan;
            scanf("%s %d:%d:%d %d:%d:%d",doorMan.name,&doorMan.startH,&doorMan.startM,&doorMan.startS
                  ,&doorMan.endH,&doorMan.endM,&doorMan.endS);
            vectorDoorMan.push_back(doorMan);
        }
        sort(vectorDoorMan.begin(),vectorDoorMan.end(),CompStartTime);
        //cout<<endl;
        DoorMan openDoorMan=vectorDoorMan[0];
        sort(vectorDoorMan.begin(),vectorDoorMan.end(),CompEndTime);
        DoorMan closeDoorMan=vectorDoorMan[0];

        //cout<<openDoorMan.name<<" "<<openDoorMan.startH<<":"<<openDoorMan.startM<<":"<<openDoorMan.startS<<" ";
        //cout<<closeDoorMan.name<<" "<<closeDoorMan.endH<<":"<<closeDoorMan.endM<<":"<<closeDoorMan.endS;
        cout<<openDoorMan.name<<" "<<closeDoorMan.name;
        cout<<endl;
    }
    return 0;
}

hdu 开门人和关门人

时间: 2024-11-24 07:25:30

hdu 开门人和关门人的相关文章

I题 hdu 1234 开门人和关门人

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234 开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12183    Accepted Submission(s): 6157 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关

HDU 1234 开门人和关门人

开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10622    Accepted Submission(s): 5419 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签 到.签离记录,请根据记录找出当天开门和关门的人. Input 测试输入的第一

HDU 1234开门人和关门人。

开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11372    Accepted Submission(s): 5786 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签 到.签离记录,请根据记录找出当天开门和关门的人. Input 测试输入的第一

杭电 HDU 1234 开门人和关门人

开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11717    Accepted Submission(s): 5949 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签 到.签离记录,请根据记录找出当天开门和关门的人. Input 测试输入的第一

hdoj 1234开门人和关门人

 /*开门人和关门人 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 5   Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把

hdoj 1234 开门人和关门人

开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) #include<stdio.h> #include<string.h> #include<algorithm> #define max 1000+10 using namespace std; struct record { char name[20]; char come[10]; c

HDU1234 开门人和关门人

开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10902    Accepted Submission(s): 5549 Problem Description 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签 到.签离记录,请根据记录找出当天开门和关门的人. Input 测试输入的第一

杭电OJ(HDU)-ACMSteps-Chapter Three-《FatMouse&amp;#39; Trade》《今年暑假不AC》《排名》《开门人和关门人》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=3 1.3.1 FatMouse' Trade #include <algorithm> /* 题意:价值/代价的比值来排序,买比值大的. Sample Input 5 3 7 2 4 3 5 2 20 3 25 18 24 15 15 10 -1 -1 Sample Output 13.333 31.500 */ #include<stdio.h>

杭电OJ(HDU)-ACMSteps-Chapter Three-《FatMouse&#39; Trade》《今年暑假不AC》《排名》《开门人和关门人》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=3 1.3.1 FatMouse' Trade #include <algorithm> /* 题意:价值/代价的比值来排序,买比值大的. Sample Input 5 3 7 2 4 3 5 2 20 3 25 18 24 15 15 10 -1 -1 Sample Output 13.333 31.500 */ #include<stdio.h>