首页 > 其他 > 详细

t.开门人和关门人

时间:2019-08-16 09:16:12      阅读:91      评论:0      收藏:0      [点我收藏+]

技术分享图片

技术分享图片

stl大法好,可以直接字典序比较string

#include<bits/stdc++.h>

using namespace std;

struct staff{
  string id;
  string start;
  string end;
};

int main(){
  ios::sync_with_stdio(false);
  // freopen("in.in", "r", stdin);
  int n, t;
  staff first;
  staff last;
  string earlist;
  string latest;
  cin >> t;
  while(t--){
    int n;
    cin >> n;
    earlist = latest = "";
    for(int i=0; i<n; i++){
      staff s;
      cin >> s.id >> s.start >> s.end;

      if(s.end > latest || latest == ""){
        latest = s.end;
        last = s;
      }

      if(s.start < earlist || earlist == ""){
        earlist = s.start;
        first = s;
      }
    }

    cout << first.id << " " << last.id << endl;
  }
  return 0;
}

 

t.开门人和关门人

原文:https://www.cnblogs.com/ssNiper/p/11361337.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!