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

18493번 - Face Recognition Algorithm 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB48402982.857%

문제

I have drawn n dots on a plane and m straight segments connecting these dots. No segment goes through dots other than its endpoints, and no two segments intersect in any point other than their common endpoint. Also, if you start in one dot and move only by segments, you can go to any other dot. All n dots are in distinct positions.

Yes, that’s a planar embedding of some connected graph with n vertices and m edges. Your task is to check if each face of this graph, including the outer face, is a triangle. Face is a triangle if and only if it is bounded by exactly 3 edges. If face is on both sides of some edge, this edge is counted twice.

Strive for excellence! Allow yourself nothing less than the best possible complexity for your algorithm.

입력

The first line contains two integers n and m (3 ≤ n ≤ 105, n − 1 ≤ m ≤ 3 · 105) — the number of dots and the number of segments, respectively.

The next n lines contain coordinates of dots. All the coordinates are not greater than 109 by absolute value. All n dots are in distinct positions.

Each of the next m lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the ids of dots connected by a segment. It is guaranteed that there are no two segments connecting the same pair of dots.

It is guaranteed that the input describes a valid planar embedding of a connected graph with all edges drawn as straight segments.

출력

If each face of the given graph, including its outer face, is a triangle, print “YES”, otherwise print “NO”.

제한

예제 입력 1

3 3
0 0
1 0
0 1
1 2
2 3
3 1

예제 출력 1

YES

예제 입력 2

4 4
0 0
3 0
0 3
1 1
1 2
2 3
3 1
1 4

예제 출력 2

NO

예제 입력 3

4 6
0 0
3 0
0 3
1 1
1 2
2 3
3 1
1 4
2 4
3 4

예제 출력 3

YES

예제 입력 4

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

예제 출력 4

NO

예제 입력 5

4 3
0 0
0 1
1 1
1 2
1 2
2 3
3 4

예제 출력 5

NO

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 8: Almost Algoritmic Contest F번

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

출처

대학교 대회

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

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