Logo
(追記) (追記ここまで)

27400번 - Restore Array 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.6 초 1024 MB222664325.444%

문제

Your task is to determine one possible binary array A of length N that abides by M given constraints of the form:

  • (l, r, k, value) - the k-th smallest element in subarray A[l..r] is value (0 ≤ l ≤ r < N, 1 ≤ k ≤ r - l + 1, 0 ≤ value ≤ 1). Please note that array A is 0-indexed.

입력

The first line of input contains two integers N and M (1 ≤ N ≤ 5 000, 1 ≤ M ≤ 10 000) - the length of array A and the number of constraints.

The next M lines describe the constraints. Each line contains four integers li, ri, ki, valuei, describing the i-th constraint.

출력

The first line of the output contains N integers - one possible binary array A. If there are several that abide by all M constraints you may output any of them. If there is no such array you must instead output the single integer -1.

제한

서브태스크

번호배점제한
17

1 ≤ N ≤ 18, 1 ≤ M ≤ 200

213

1 ≤ N ≤ 5 000, 1 ≤ M ≤ 10 000, for all constraints k = 1 holds

325

1 ≤ N ≤ 5 000, 1 ≤ M ≤ 10 000, for all constraints k = 1 or k = (r - l + 1) holds

455

1 ≤ N ≤ 5 000, 1 ≤ M ≤ 10 000

예제 입력 1

4 5
0 1 2 1
0 2 2 0
2 2 1 0
0 1 1 0
1 2 1 0

예제 출력 1

0 1 0 0

힌트

There are several binary arrays that abide by all the constraints. One of them is 0 1 0 0 because:

  1. The 2-nd smallest element among 0 1 (削除) 0 0 (削除ここまで) is 1.
  2. The 2-nd smallest element among 0 1 0 (削除) 0 (削除ここまで) is 0.
  3. The 1-st smallest element among (削除) 0 1 (削除ここまで) 0 (削除) 0 (削除ここまで) is 0.
  4. The 1-st smallest element among 0 1 (削除) 0 0 (削除ここまで) is 0.
  5. The 1-st smallest element among (削除) 0 (削除ここまで) 1 0 (削除) 0 (削除ここまで) is 0.

출처

Olympiad > Romanian Master of Informatics > Romanian Master of Informatics 2019 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /