← 返回 openai 的题目列表Balanced Sequence Generation for (AI, Human, Task) Tags with Prefix Constraints
类型:online_judge
General Coding: Generate a Balanced Pair-Tag Sequence with Prefix Constraints
There are three tags: AI, Human, Task. Each day you output a pair (two tags) chosen from:
AI-Human
AI-Task
Human-Task
Given an integer (N), generate a length-(N) sequence seq[1..N].
Constraint 1 (basic balance)
For every prefix length (1 \le n \le N), within seq[1..n]:
the absolute difference between the occurrence counts of AI and Human is (\le 1).
Each pair contributes +1 to the count of each tag it contains.
Constraint 2 (advanced balance)
In addition to Constraint 1, require that for every prefix (1 \le n \le N):
the absolute difference between the occurrence counts of AI and Task is (\le 1).
Output
Print (N) pairs, one per line (e.g., AI-Human). Any valid sequence is accepted.
Constraints
(1 \le N \le 10^5)
Examples
N=1 -> AI-Human
N=4 -> any sequence satisfying both prefix-balance constraints.
Note: This is a reconstructed statement from an interview report; the exact set of allowed pairs and thresholds may differ in the original.
Example
Input
1
Output
AI-Human