class Point:

def init(self, a=0, b=0):

self.x = a

self.y = b

代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可

能回到1号点返回 Yes,否则返回 No

@param param int整型一维数组 param[0] 为 n,param[1] 为 m

@param edge Point类一维数组 Point.x , Point.y 分别为一条边的两个点

@return string字符串

class Solution:
def move(self, s, record, n, step):
if s == 0 and step > 0:
return True

    for i in range(0, n):
        if record[s][i] == 1:
            record[i][s] = 0
            record[s][i] = 0
            if self.move(i, record, n, step+1):
                return True
            record[i][s] = 1
            record[s][i] = 1
    return False

def solve(self , param , edge ):
    # write code here
    n, m = param[0], param[1]
    record = [[0 for _ in range(n)] for _ in range(n)] 
    for i in range(m):
        temp = edge[i]
        x = temp.x-1
        y = temp.y-1
        record[x][y] = 1
        record[y][x] = 1
    s = 0
    step = 0
    if self.move(s, record, n, step):
        return 'Yes'
    else:
        return 'No'