A logistics operator flags one client account by name after a dispute, and now needs to know which field agents have a completely clear record with that account: agents who have never been assigned to fulfil an order for any client sharing the flagged name.
Line 1: three integers A, C, O — the number of field agents, the number of client accounts, and the number of orders.
Next A lines: each contains an integer agent_id and a string agent_name (a token of letters and digits, 1–30 characters). Agent ids are distinct.
Next C lines: each contains an integer client_id and a string client_name (a token of letters and digits, 1–30 characters). Client ids are distinct, but client names need not be — more than one client account can share the same name.
Next O lines: each contains three integers order_id, client_id, and agent_id, describing one order fulfilled by that agent for that client. order_id values are distinct; client_id and agent_id each refer to entries listed above.
Last line: a single string flagged_name (a token of letters and digits, 1–30 characters).
Print the name of every field agent who was never assigned an order for any client whose name equals flagged_name, one name per line, sorted alphabetically ascending. (An agent with zero orders in total automatically qualifies.) If no agent qualifies, print a single line containing NONE.
Example 1
Input
3 2 2 1 Amara 2 Rohan 3 Priya 10 RedFin 20 BlueOx 101 10 1 102 20 2 RedFin
Expected
Priya Rohan
Explanation
Agent 1 (Amara) fulfilled order 101 for client 10, whose name is RedFin — the flagged name — so Amara is excluded. Agent 2 (Rohan) only fulfilled order 102 for client 20 (BlueOx), which is not flagged, so Rohan qualifies. Agent 3 (Priya) has no orders at all, so she automatically qualifies. Sorted alphabetically, the output is Priya then Rohan.
Example 2
Input
2 1 1 1 Zoe 2 Ana 5 Acme 201 5 1 Ghost
Expected
Ana Zoe
Explanation
The flagged name is Ghost, but no client is named Ghost (the only client, Acme, doesn't match), so no order is tied to a flagged client. Every agent, including Zoe who fulfilled order 201, qualifies. Sorted alphabetically: Ana then Zoe.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →