F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Pty loves graph

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 121    Accepted Submission(s): 24


Problem Description
Given a undirected graph and a Hamiltonian cycle of it, output whether it is a planar graph.

For convenience, the indices of vertex are advancely relabeled so that the given Hamiltonian cycle is 1--2--3--4--...--(n-1)--n--1. The edges on this cycle are not given in the input.

Notice that there might be self loops and multiedges in the graph.

There are T test cases in total.
 

Input
The first line contains one integer T – the number of test cases.

For each test case:

The first line, two positive integer N,M - the number of vertices and edge besides the Hamiltonian cycle. Following m lines, two positive integer x,y, representing an edge (x,y)

1 ≤ T ≤ 26
1 ≤ N,M ≤ 5×$10^5$ , $\sum N$,$ \sum M ≤ 3 \times 10^6$.
1 ≤ x,y ≤ N
 

Output
For each test case, output ”Yes” or ”No” in one line.
 

Sample Input
2 5 5 1 3 1 4 2 4 2 5 3 5 4 4 1 3 2 4 2 2 1 2
 

Sample Output
No Yes
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 08:46:59, Gzip enabled