fork(1) download
  1. const fi = '';
  2. fo = '';
  3. maxn = 500;
  4. var n:longint;
  5. a: array[1..maxn,1..maxn] of boolean;
  6. l,r: array[1..maxn] of longint;
  7. procedure enter;
  8. var i,j,k,p:longint;
  9. begin
  10. readln(n);
  11. for i:=1 to n do
  12. begin
  13. for j:=1 to n do
  14. begin
  15. read(p);
  16. a[i,j]:=(p=1);
  17. if a[i,j] then inc(l[i]);
  18. end;
  19. readln;
  20. end;
  21. for i:=1 to n do
  22. for j:=1 to n do
  23. for k:=1 to n do
  24. if not a[i,j] and a[i,k] and a[k,j] then
  25. begin
  26. a[i,j]:=true;
  27. inc(l[i]);
  28. end;
  29. end;
  30. procedure solve;
  31. var i,j:longint;
  32. res:longint;
  33. begin
  34. res:=0;
  35. for i:=1 to n do
  36. if l[i]=n then
  37. begin
  38. inc(res);
  39. r[res]:=i;
  40. end;
  41. writeln(res);
  42. for i:=1 to res do
  43. writeln(r[i]);
  44. end;
  45. begin
  46. assign(input,fi);
  47. reset(input);
  48. assign(output,fo);
  49. rewrite(output);
  50. enter;
  51. solve;
  52. close(input);
  53. close(output);
  54. end.
  55.  
Success #stdin #stdout 0s 524KB
stdin
Standard input is empty
stdout
0