题解 | #幼儿园分班#
幼儿园分班
https://www.nowcoder.com/practice/e503f18d56754ad9bcf8631adf63721d
def cls(): m = int(input()) n = int(input()) ls = [] cls1 = [] cls2 = [] for i in range(n): a,b = map(int,input().strip().split()) if a in cls1: cls2.append(b) elif a in cls2: cls1.append(b) else: cls1.append(a) cls2.append(b) ls.append(a) ls.append(b) res = sorted(list(set(cls1)) + list(set(cls2))) ls_res = sorted(list(set(ls))) if res == ls_res: print(1) else: print(0) cls()