Skip to content

Instantly share code, notes, and snippets.

@IKKO-Ohta
Created September 14, 2017 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IKKO-Ohta/1de9ec8e838070dec6f278fc16cc44c2 to your computer and use it in GitHub Desktop.
Save IKKO-Ohta/1de9ec8e838070dec6f278fc16cc44c2 to your computer and use it in GitHub Desktop.
ABC002[D].py
import itertools
nums = [int(x) for x in input().split()]
N,M = nums[0],nums[1]
# make
matrix = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
nums=[int(x) for x in input().split()]
a,b = nums[0]-1,nums[1]-1
matrix[a][b] = 1
matrix[b][a] = 1
patterns = [i for i in itertools.product([0,1], repeat=N)]
ans = 0
for pat in patterns:
choice = [i for i in range(len(pat)) if pat[i] != 0]
if all([matrix[l[0]][l[1]] for l in list(itertools.combinations(choice,2))]):
ans = max(ans,len(choice))
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment