fork download
  1. def parse(inFile):
  2. N = inFile.getInt()
  3. return [[z - 1 for z in inFile.getInts()[1:]] for k in xrange(N)]
  4.  
  5. def solve(dependents):
  6. N = len(dependents)
  7. for i in xrange(N):
  8. dep = [False] * N
  9. q = [i]
  10. while (len(q)):
  11. for j in dependents[q.pop()]:
  12. if (dep[j]):
  13. return "Yes"
  14. dep[j] = True
  15. q.append(j)
  16. return "No"
  17.  
  18. if __name__ == "__main__":
  19. from GCJ import GCJ
  20. GCJ(parse, solve, "/Users/lpebody/gcj/setup/", "a").run()
  21.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty