← 返回 sofi 的题目列表Count completed trips from vehicle event logs (entry -> road -> exit)
类型:online_judge
Problem
You are given text logs for multiple vehicles (each record includes a license plate and an event type). Event types are: entry, road, exit.
A trip is counted when the same plate appears in chronological order with a complete sequence:
entry -> road -> exit
Implement get_trip(logs) (or an equivalent program) to return the total number of completed trips.
Input
A list/stream of log records in time order.
Each record contains at least: plate and event.
Output
An integer: total number of completed trips.
Notes / Assumptions
Only full entry -> road -> exit sequences count.
The same plate may complete multiple trips.
Explain how you handle invalid or incomplete sequences (e.g., missing entry, repeated entry, exit before entry).
Sample Tests (illustrative)
(Using plate event per line; actual interview format may differ.)
A entry
A road
A exit
Output:
1
A entry
A exit
A road
Output:
0
A entry
A road
A exit
A entry
A road
A exit
Output:
2
A road
A exit
Output:
0
A entry
B entry
A road
B road
A exit
B exit
Output:
2
Example
Input
3
A entry
A road
A exit
Output
1