fork download
  1. Program figura;
  2. var
  3. v:array[-1..1000,-1..1000] of integer;
  4. d,n,i,j,s,a,b,r,x,k:integer;
  5. f1,f2:text;
  6. begin
  7. assign(f1,'figura.in');
  8. assign(f2,'figura.out');
  9. reset(f1);
  10. rewrite(f2);
  11. readln(d);
  12. readln(n);
  13. x:=0;
  14.  
  15. for k:=1 to n do begin
  16. readln(a,b);
  17. v[a,b]:=1;
  18. end;
  19.  
  20. for i:=0 to d+1 do begin
  21. for j:=0 to d+1 do begin
  22. if v[i,j]=0 then begin
  23. if (v[i-1,j]=1) then x:=x+1;
  24. if (v[i+1,j]=1) then x:=x+1;
  25. if (v[i,j-1]=1) then x:=x+1;
  26. if (v[i,j+1]=1) then x:=x+1;
  27. end;
  28. end;
  29. end;
  30. writeln(x);
  31.  
  32. close(f1);
  33. close(f2);
  34. end.
  35.  
Runtime error #stdin #stdout 0.01s 2216KB
stdin
6
3
1 1
1 2
2 1
stdout
Runtime error 2 at $080480DE
  $080480DE
  $0805F051