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

32471번 - Same Segment 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)158312521.930%

문제

You have a sequence $a$ of $N$ integers between 0ドル$ and $K$ inclusive. $M$ segments are given, where $i$th segment is $[l_i,r_i]$. We want $\sum_{j=l_i}^{r_i}a_j=K$ to satisfy for every segment. Determine whether there exists such sequence $a$.

입력

Each test data contains one or more test cases. The first line contains an integer $T$ — the number of test cases for this input file.

First line of each test case contains 3ドル$ integers $N,ドル $M,ドル $K$.

$i$-th of the next $M$ lines contain two integers $l_i$ and $r_i$: left and right end of $i$-th segment.

출력

For each test case, if a sequence that satisfies the condition exists, output the elements of the sequence. In case of multiple answers you may output any of them.

If no valid sequence exists, output a single integer $-1$.

제한

  • 1ドル\leq T\leq 10^5$
  • 2ドル\leq N\leq 4\times 10^5$
  • 1ドル\leq M\leq\min\left( 2\times 10^5,\frac{N(N+1)}{2} \right)$
  • 1ドル\leq K\leq 20$
  • 1ドル\leq l_i\leq r_i\leq N$
  • $(l_i,r_i)\neq(l_j,r_j)$ for $i\neq j$
  • Sum of $N$ over every test case does not exceed 4ドル\times 10^5$.
  • Sum of $M$ over every test case does not exceed 2ドル\times 10^5$.

예제 입력 1

4
6 3 3
1 3
2 4
3 5
4 6 2
1 2
1 3
1 4
2 3
2 4
3 4
4 4 1
1 2
3 4
1 3
2 4
3 3 10
1 1
2 2
3 3

예제 출력 1

1 1 1 1 1 1
-1
1 0 0 1
10 10 10

노트

출처

University > KAIST > KAIST ICPC Mock Competition > 2024 KAIST 14th ICPC Mock Competition K번

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

출처

대학교 대회

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

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