PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000040. Phát hiện sự kiện đồng thời (Identifying Concurrent Events)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phát hiện sự kiện đồng thời (Identifying Concurrent Events)
Identifying Concurrent Events
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given sequences of ordered events and inter-sequence messages, two events are concurrent if neither precedes the other. Count unordered concurrent pairs and report the first two pairs.
Input
Integer computation sequences; each sequence line starts with then event names in chronological order; then and sender/receiver event-name pairs.
Output
Print the count of concurrent pairs, then up to two lines (event1,event2) ordered by the input occurrence of events.
Subtasks
- Subtask 1 (40 points): ; , per sequence, at most events overall, ; unique 1–5 alphanumeric event names, acyclic precedence relation.
- Subtask 2 (60 points): , per sequence, at most events overall, ; unique 1–5 alphanumeric event names, acyclic precedence relation.
Examples
Input
2
2 e1 e2
2 e3 e4
1
e3 e1
Output
2
(e1,e4)
(e2,e4)
Explanation
Sequence order and the additional message imply all relevant precedence except for (e1,e4) and (e2,e4), leaving exactly two concurrent unordered pairs.