```
def can_finish(num_courses, prerequisites)
graph=[]
num_courses.times{graph<<[]}
visited=[0]*num_courses
prerequisites.each { |cur,pre| graph[pre]<< cur }
num_courses.times {|i| return false if visited[i]==0 && !dfs(graph,visited,i) }
true
end
def dfs(graph,visited,i)
return false if visited[i]==1
visited[i]=1
graph[i].each {|nex| return false if !dfs(graph,visited,nex) }
visited[i]=2
end
```

I have checked my code with others, my code seems no problem.

If oj system is ok, how should i modify my code?