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. readln(d);
  8. readln(n);
  9. x:=0;
  10.  
  11. for k:=1 to n do begin
  12. readln(a,b);
  13. v[a,b]:=1;
  14. end;
  15.  
  16. for i:=0 to d+1 do begin
  17. for j:=0 to d+1 do begin
  18. if v[i,j]=0 then begin
  19. if (v[i-1,j]=1) then x:=x+1;
  20. if (v[i+1,j]=1) then x:=x+1;
  21. if (v[i,j-1]=1) then x:=x+1;
  22. if (v[i,j+1]=1) then x:=x+1;
  23. end;
  24. end;
  25. end;
  26. writeln(x);
  27. end.
  28.  
Success #stdin #stdout 0.02s 2216KB
stdin
6
3
1 1
1 2
2 1
stdout
8