PaypalOA #2
Count User Logins (Singapore)
简单可在线判题
Count how many times each username logs in on each valid date; discard records with an invalid time or date, and output in lexicographic order of username and date. The two explanations in the source examples disagree with the counts in the sample input/output, so this site recomputes them from the input data and the explicit rules; the output fields keep the userX form used in the examples and in the source reference implementation.
输入格式
The first line contains n; each of the next n lines is user<ID> HH:MM:SS YYYY-MM-DD. Added by this site: 1≤n≤1000; ID is a canonical decimal non-negative integer in 0..10^9; the year is in 2000..3000. The time must lie within 00:00:00..23:59:59 and the date must be a valid Gregorian calendar date; lines with an invalid time/date are ignored.
输出格式
First output k, the number of valid (user, date) groups; then output k lines, each user<ID> YYYY-MM-DD followed by the login count, sorted by the username string ascending, then by date ascending. If there are no valid records, output 0.
样例 1
输入:
5
user1 09:00:00 2021-01-01
user1 13:00:00 2021-01-01
user2 14:00:00 2021-01-01
user1 20:00:00 2021-01-02
user2 21:00:00 2021-01-01
输出:
3
user1 2021-01-01 2
user1 2021-01-02 1
user2 2021-01-01 2
样例 2
输入:
7
user1 09:00:00 2021-01-01
user1 13:00:00 2021-01-01
user2 14:00:00 2021-01-01
user1 20:00:00 2021-01-01
user2 21:00:00 2021-01-01
user3 25:00:00 2021-01-01
user4 22:00:00 2021-02-29
输出:
2
user1 2021-01-01 3
user2 2021-01-01 2
样例 3
输入:
3
user2 10:00:00 2024-03-01
user10 11:00:00 2024-02-29
user2 12:00:00 2024-02-29
输出:
3
user10 2024-02-29 1
user2 2024-02-29 1
user2 2024-03-01 1