AmazonOA #121
Count Faults
Estimated EasyJudge-ready
Topics (AI-labelled)SimulationHashing
Observe each server's own requests separately; after three consecutive error results, replace the server and reset its consecutive error count to zero, and a success also resets it. Logs from other servers do not interrupt a server's consecutive requests.
Input
The first line contains n m; each of the next m lines contains a server number (1-based) and success/error. 1≤n≤200, 1≤m≤20000.
Output
Output a single integer answer.
Example 1
Input:
2 6
1 error
1 error
2 error
1 error
1 error
2 success
Output:
1
Example 2
Input:
1 6
1 error
1 error
1 error
1 error
1 error
1 error
Output:
2
Example 3
Input:
1 4
1 error
1 success
1 error
1 error
Output:
0
Example notes
Example 1: s1 is replaced once when its third error occurs, followed by only one more error, so the answer is 1. Example 2: six errors in a row cause a replacement every three, so the answer is 2. Example 3: a success interrupts the consecutive errors, so the answer is 0.
Editorial
Loading solution…