55. Transaction Monitoring System

Difficulty: easy · Hashing, Simulation

Problem

A financial platform processes `N` transactions in the order given. Each transaction has a sender, a receiver, a timestamp (in seconds) and an amount. Process the transactions one by one and stop at the first rule that fails: 1. **Duplicate:** if the current transaction has the same sender **and** the same receiver as any earlier transaction, print `Error: Duplicate Transaction` and stop. 2. **Fraud:** otherwise, if this is not the first transaction and its timestamp minus the previous transaction's timestamp is greater than 60, print `Fraud Detected` and stop. If every transaction passes both checks, print `All Transactions Valid`.

Input

- Line 1: the integer `N`. - Next `N` lines: `sender receiver timestamp amount`, separated by spaces. Sender and receiver are strings without spaces.

Output

Print exactly one of `Error: Duplicate Transaction`, `Fraud Detected`, `All Transactions Valid`.

Example 1

Input:
3
A B 10 100
C D 50 200
E F 90 300
Output:
All Transactions Valid

Explanation: All sender-receiver pairs are different and the gaps (40 and 40 seconds) are at most 60.

Example 2

Input:
2
A B 100 500
A B 110 600
Output:
Error: Duplicate Transaction

Explanation: The second transaction repeats the pair A -> B.

Example 3

Input:
2
A B 100 500
C D 200 300
Output:
Fraud Detected

Explanation: The pairs differ, but the gap of 100 seconds is more than 60.

Constraints

- 1 <= N <= 10^5 - Sender and receiver consist of 1 to 10 letters or digits - 0 <= timestamp <= 10^9, timestamps are non-decreasing - 0 <= amount <= 10^9

Solutions are judged against 3 sample and 9 hidden tests. Sign in to solve it · All problems