3 1 ME3021112225321 00:00:00 23:59:59 2 EE301218 08:05:35 20:56:35 MA301134 12:35:45 21:40:42 3 CS301111 15:30:28 17:00:10 SC3021234 08:00:00 11:25:25 CS301133 21:45:00 21:58:40
ME3021112225321 ME3021112225321 EE301218 MA301134 SC3021234 CS301133
水題,不解釋了,就是簡單的字符串應用。
AC代碼:
#include#include #include #include using namespace std; struct man { string id, st, et; //人的編號,簽到時間,簽退時間 }; man m[10005]; bool cmp1(man a, man b){ int x = (a.st[0]-'0')*10 + (a.st[1]-'0'); int xx = (a.st[3]-'0')*10 + (a.st[4]-'0'); int xxx = (a.st[6]-'0')*10 + (a.st[7]-'0'); int y = (b.st[0]-'0')*10 + (b.st[1]-'0'); int yy = (b.st[3]-'0')*10 + (b.st[4]-'0'); int yyy = (b.st[6]-'0')*10 + (b.st[7]-'0'); if(x==y && xx==yy) return xxx < yyy; else if(x==y) return xx < yy; return x < y; } bool cmp2(man a, man b){ int x = (a.et[0]-'0')*10 + (a.et[1]-'0'); int xx = (a.et[3]-'0')*10 + (a.et[4]-'0'); int xxx = (a.et[6]-'0')*10 + (a.et[7]-'0'); int y = (b.et[0]-'0')*10 + (b.et[1]-'0'); int yy = (b.et[3]-'0')*10 + (b.et[4]-'0'); int yyy = (b.et[6]-'0')*10 + (b.et[7]-'0'); if(x==y && xx==yy) return xxx > yyy; else if(x==y) return xx > yy; return x > y; } int main(){ // freopen("in.txt", "r", stdin); int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); for(int i=0; i > m[i].id >> m[i].st >> m[i].et; sort(m, m+n, cmp1); cout << m[0].id<<" "; sort(m, m+n, cmp2); cout << m[0].id << endl; } return 0; }