
#include <stdio.h>
#include <string.h>
#define MAX_BOOKS 1001 // 书号最大为1000
typedef struct {
int start_hh, start_mm; // 借书时间
int end_hh, end_mm; // 还书时间
int is_borrowed; // 标记是否被借出
} BookRecord;
// 计算时间差(分钟)
int time_diff(int start_hh, int start_mm, int end_hh, int end_mm) {
return (end_hh - start_hh) * 60 + (end_mm - start_mm);
}
int main() {
int N;
scanf("%d", &N); // 输入天数
for (int day = 0; day < N; day++) {
BookRecord books[MAX_BOOKS] = {0}; // 初始化每天的借阅记录
int book_id, hh, mm;
char key;
int total_borrows = 0; // 当天借书次数
int total_time = 0; // 当天总阅读时间
while (1) {
scanf("%d %c %d:%d", &book_id, &key, &hh, &mm); // 输入操作记录
if (book_id == 0) { // 如果书号为0,表示一天结束
break;
}
if (key == 'S') { // 借书操作
books[book_id].start_hh = hh;
books[book_id].start_mm = mm;
books[book_id].is_borrowed = 1; // 标记为已借出
} else if (key == 'E' && books[book_id].is_borrowed==1) { // 还书操作且之前有借书记录
books[book_id].end_hh = hh;
books[book_id].end_mm = mm;
total_time += time_diff(books[book_id].start_hh, books[book_id].start_mm,
books[book_id].end_hh, books[book_id].end_mm);
total_borrows++;
books[book_id].is_borrowed = 0; // 标记为已归还
}
}
// 输出当天的借书次数和平均阅读时间
if (total_borrows == 0) {
printf("0 0\n");
} else {
printf("%d %.0lf\n", total_borrows,(double) total_time / total_borrows);//实现四舍五入
}
}
return 0;
}