A conservation NGO scatters motion-triggered trail cameras across a nature reserve. Whenever a remote reviewer opens a captured clip, the monitoring system appends a log line recording which camera captured the clip, which ranger the camera is assigned to, which reviewer opened it, and the calendar day the review happened. Ranger assignments rotate independently of review activity and are not relevant to this task -- they only appear in the log because they are part of the shared record format.
The operations team wants to flag any reviewer who, on at least one single day, opened clips originating from more than one distinct camera. Opening the same camera's clip multiple times on the same day does not count as visiting a second camera. Given the complete log, output every reviewer id that meets this condition on at least one day.
The first line contains a single integer n, the number of log entries. Each of the next n lines contains four integers: camera_id, ranger_id, reviewer_id, day -- describing one clip-opening event.
Print the distinct qualifying reviewer ids, in strictly increasing order, separated by single spaces on one line. If no reviewer qualifies, print an empty line.
1 <= n <= 2 * 10^5 1 <= camera_id, ranger_id, reviewer_id, day <= 10^9 Log entries may repeat exactly (the same camera opened by the same reviewer on the same day more than once).
Example 1
Input
5 1 100 5 1 2 100 5 1 3 100 6 1 1 100 6 2 2 100 6 2
Expected
5 6
Explanation
Reviewer 5 opens clips from cameras 1 and 2 on day 1 (two distinct cameras on one day), so reviewer 5 qualifies. Reviewer 6 opens only camera 3 on day 1 (just one camera), but on day 2 opens cameras 1 and 2 (two distinct cameras), so reviewer 6 also qualifies. Sorted ascending, the output is "5 6".
Example 2
Input
3 7 200 9 5 7 200 9 5 7 200 10 5
Expected
(empty)Explanation
Reviewer 9 opens camera 7's clip twice on day 5 -- that is still only one distinct camera, so reviewer 9 does not qualify. Reviewer 10 opens only camera 7 on day 5. No reviewer ever touches more than one distinct camera on the same day, so the output is an empty line.
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 →