Topological Sorting by 51b

s[700];t[99];char*p;n,k,*q;main(m,u){for(;p=gets(u);)for(q=s+7*++n;*p;*p&&p++)*q++=strtol(p,&p,0);for(;m<=n;k?printf("%d\n",m),m=t[m]=1:m++)for(k=!t[m],q=s+7*m;*++q;)k*=t[*q];}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page