fork download
  1. uses math;
  2. const fi = '';
  3. fo = '';
  4. maxN = 20005;
  5. maxM = 50005;
  6. var u, v : array[0..maxM] of longint;
  7. ke : array[0..2*maxM] of longint;
  8. dau, is_khop : array[0..maxN] of longint;
  9. n, m, dfscount, rootcon, rootvertex, nCon : longint;
  10. num, low : array[0..maxN] of longint;
  11.  
  12. procedure init;
  13. var i : longint;
  14. begin
  15. readln(n,m);
  16. for i:=1 to m do
  17. begin
  18. readln(u[i],v[i]);
  19. inc(dau[u[i]]);
  20. inc(dau[v[i]]);
  21. end;
  22. for i:=2 to n do dau[i]:=dau[i-1]+dau[i];
  23. dau[n+1]:=2*m;
  24.  
  25. for i:=1 to m do
  26. begin
  27. ke[dau[u[i]]]:=v[i];
  28. ke[dau[v[i]]]:=u[i];
  29. dec(dau[u[i]]);
  30. dec(dau[v[i]]);
  31. end;
  32. end;
  33.  
  34. procedure visit(u : longint);
  35. var v, i :longint;
  36. begin
  37. inc(dfscount);
  38. low[u]:=dfscount; num[u]:=dfscount;
  39. for i:=dau[u]+1 to dau[u+1] do
  40. begin
  41. v:=ke[i];
  42. if num[v]=0 then
  43. begin
  44. if u = rootvertex then inc(rootcon);
  45. visit(v);
  46. if low[v] >= num[u] then inc(is_khop[u])
  47. else low[u]:=min(low[u],low[v]);
  48. end
  49. else low[u]:=min(low[u],num[v]);
  50. end;
  51. end;
  52.  
  53. procedure solve;
  54. var u : longint;
  55. begin
  56. dfscount:=0; nCon:=0;
  57. fillchar(is_khop,sizeof(is_khop),0);
  58. fillchar(num,sizeof(num),0);
  59. for u:=1 to n do
  60. if num[u]=0 then
  61. begin
  62. inc(nCon);
  63. visit(u);
  64. dec(is_khop[u]);
  65. end;
  66.  
  67. for u:=1 to n do writeln(is_khop[u]+nCon);
  68. end;
  69.  
  70. begin
  71. assign(input,fi);reset(input);
  72. assign(output,fo);rewrite(output);
  73. init;
  74. solve;
  75. close(input);close(output);
  76. end.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.pas:1: warning: missing program header
prog.pas:1: error: module/unit interface `math' could not be imported
stdout
Standard output is empty