제출 #971513

#제출 시각아이디문제언어결과실행 시간메모리
971513Lcc735Railway (BOI17_railway)Cpython 3
0 / 100
1018 ms45248 KiB
n,m,k=map(int,input().split()) caminos=[] pedido=[] nodos=[] ady=[] for i in range(n): nodos.append([]) ady.append([]) for i in range(n-1): a,b=map(int,input().split()) a-=1 b-=1 caminos.append([a,b]) pedido.append(0) nodos[a].append(i) ady[a].append(b) nodos[b].append(i) ady[b].append(a) def llegar(a,b,pasado,soli,nodo,adyac): for i in range(len(adyac)): c=adyac[i] if(c==b): soli.add(nodo[i]) return True else: if(c not in pasado): pasado.add(c) if (llegar(c,b,pasado,soli,nodos[c],ady[c])): pasado.add(c) soli.add(nodo[i]) return True for i in range(m): soli=set() s=input().split() for i in range(1,len(s)-1): a=int(s[i])-1 b=int(s[i+1])-1 pasado=set() pasado.add(a) llegar(a,b,pasado,soli,nodos[a],ady[a]) for i in soli: pedido[i]+=1 ok=[] for i in range(len(pedido)): if(pedido[i]>=k): ok.append(i) print(len(ok)) for i in ok: print(i+1,end=' ') print('')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...