fork(1) download
  1. const fi='';
  2. nmax=40000;
  3. mmax=100000;
  4. type
  5. data=longint;
  6. data1=longint;
  7. var
  8. f:text;
  9. n,m:data;
  10. head:array[0..nmax+1] of data1;
  11. adj:array[0..mmax*2] of data1;
  12. loaidinh,DD:array[0..nmax] of boolean;
  13. A,B:array[0..2*mmax] of data1;
  14.  
  15. procedure sort(l,r: longint);
  16. var
  17. i,j: longint;
  18. x,y:data1;
  19. begin
  20. i:=l;
  21. j:=r;
  22. x:=a[(l+r) div 2];
  23. repeat
  24. while a[i]<x do
  25. inc(i);
  26. while x<a[j] do
  27. dec(j);
  28. if not(i>j) then
  29. begin
  30. y:=a[i]; a[i]:=a[j]; a[j]:=y;
  31. y:=b[i]; b[i]:=b[j]; b[j]:=y;
  32. inc(i);
  33. j:=j-1;
  34. end;
  35. until i>j;
  36. if l<j then
  37. sort(l,j);
  38. if i<r then
  39. sort(i,r);
  40. end;
  41.  
  42.  
  43.  
  44. procedure docfile;
  45. var i,j:data;
  46. u,v:data1;
  47. dem:data;
  48. begin
  49. assign(f,fi); reset(f);
  50. readln(f,n,m);
  51. head[0]:=0;
  52. for i:=1 to m do
  53. begin
  54. readln(f,u,v);
  55. A[(i-1)*2+1]:=u;
  56. B[(i-1)*2+1]:=v;
  57. A[(i-1)*2+2]:=v;
  58. B[(i-1)*2+2]:=u;
  59. end;
  60. close(f);
  61. sort(1,2*m);
  62. head[0]:=0;
  63. for i:=1 to 2*m do
  64. begin
  65. adj[i]:=b[i];
  66. inc(head[a[i]]);
  67. end;
  68. for i:=1 to n do
  69. head[i]:=head[i-1]+head[i];
  70. end;
  71.  
  72. procedure init;
  73. var i:data;
  74. begin
  75. for i:=1 to n do dd[i]:=false;
  76. end;
  77.  
  78. procedure dfs(i:data);
  79. var j:data;
  80. begin
  81. if loaidinh[i] then
  82. exit;
  83. dd[i]:=true;
  84. for j:=head[i-1]+1 to head[i] do
  85. if not (dd[adj[j]]) then
  86. dfs(adj[j]);
  87. end;
  88.  
  89. function STPLT:data;
  90. var i:data;
  91. s:data;
  92. begin
  93. s:=0;
  94. init;
  95. for i:=1 to n do
  96. if not dd[i] then
  97. begin
  98. inc(s);
  99. dfs(i);
  100. end;
  101. exit(s);
  102. end;
  103.  
  104. procedure xuli;
  105. var i:data;
  106. begin
  107. for i:=1 to n do
  108. loaidinh[i]:=false;
  109.  
  110. for i:=1 to n do
  111. begin
  112. loaidinh[i]:=true;
  113. writeln(stplt-1);
  114. loaidinh[i]:=false;
  115. end;
  116. end;
  117.  
  118. begin
  119. docfile;
  120. xuli;
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Free Pascal Compiler version 2.6.4+dfsg-6 [2015/05/31] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling prog.pas
prog.pas(45,11) Note: Local variable "j" not used
prog.pas(47,9) Note: Local variable "dem" not used
prog.pas(120,13) Fatal: Unexpected end of file
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
stdout
Standard output is empty