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

23394번 - Handling the Blocks 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB90545159.302%

문제

A friend of yours invented a game and wants to know if you can solve it or if it’s impossible.

He assembled a sequence of N blocks. Each block has a number engraved on it and some color. All numbers are distinct and between 1 and N, and different blocks can be of the same color.

The game works as follows: you can play as many turns as you want. In one turn, you choose two different blocks that share the same color and swap them.

You have to tell whether it is possible to get the entire sequence to be sorted into ascending order by numbers engraved on the blocks.

입력

The first line contains two integers N and K (1 ≤ N ≤ 105, 1 ≤ K ≤ N), representing the number of blocks in the sequence and the number of different colors, respectively.

Each of the next N lines contains two integers ni and ci (1 ≤ ni ≤ N, 1 ≤ ci ≤ K), representing the number and color of the i-th block, respectively.

출력

Output one line containing one character. If the sequence can be arranged in ascending order, write the upper case letter ‘Y’; otherwise write the uppercase letter ‘N’.

제한

예제 입력 1

4 2
3 1
4 2
1 1
2 2

예제 출력 1

Y

예제 입력 2

4 2
2 1
4 2
1 1
3 2

예제 출력 2

N

예제 입력 3

3 1
1 1
2 1
3 1

예제 출력 3

Y

힌트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona de Programação SBC 2021 H번

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

출처

대학교 대회

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

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