Handcrafted Gift

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Adam is making Bob a hand-crafted necklace as a gift. A necklace consists of nn beads, numbered 00 to n1n-1 from left to right. Each bead can either be red or blue in colour. Bob has sent Adam a list of rr requirements for the necklace. The iith requirement (0i<r0 \leq i \lt r) states that the beads from positions a\[i]a\[i] to b\[i]b\[i] inclusive should have x\[i]x\[i] unique colours. 

Help Adam find a possible configuration of beads that satisfies all of Bob's requirements, or determine that it is impossible.

제한

  • 1n,r500;0001 \leq n, r \leq 500\\;000
  • 0a\[i]b\[i]n10 \leq a\[i] \leq b\[i] \leq n-1 (for all 0in10 \leq i \leq n-1)
  • 1x\[i]21 \leq x\[i] \leq 2 (for all 0in10 \leq i \leq n-1)