⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac1094.pas

📁 某牛人写的acm.tongji.edu.cn上大部分ac的代码,仅供学习研究,请不要用来作弊
💻 PAS
字号:
program tju1094;
const
  maxn=76;
  maxm=100;
var
  cut:array[1..maxm]of record r1,c1,r2,c2:byte;end;
  ok:array[1..maxn]of boolean;
  n,m,l,r,i,j,count:longint;
  a,b,c,d:byte;
procedure readvtx(var r,c:byte);
  var
    x,t:word;
  begin
    read(x);
    t:=trunc(sqrt(x*2-1.75)-0.5);
    r:=t+1;c:=x-t*(t+1) shr 1;
  end;
function min(a,b:byte):byte;
  begin
    if a<b then min:=a else min:=b;
  end;
function max(a,b:byte):byte;
  begin
    if a>b then max:=a else max:=b;
  end;
procedure go(x,y:byte);
  var
    u,d,i:byte;
  begin
    u:=x-min(y-1,x-y);d:=n;
    for i:=1 to l do
      if (y=cut[i].c1) and (y=cut[i].c2) or
         (cut[i].r1-x=cut[i].c1-y) and (cut[i].r2-x=cut[i].c2-y) then
        if cut[i].r1<x then
          u:=max(u,cut[i].r2)
        else
          d:=min(d,cut[i].r1);
    for i:=u to d do
      ok[i]:=true;
    ok[x]:=false;
    for i:=r to m do
      if ((cut[i].r1<x) and (cut[i].c1>=y-x+cut[i].r1) and (cut[i].c2<=y)) or
         ((cut[i].r1>x) and (cut[i].c1>=y) and (cut[i].c2<=y-x+cut[i].r1)) then
        ok[cut[i].r1]:=false;
    for i:=u to d do
      if ok[i] then inc(count);
  end;
begin
  repeat
    read(n,m);
    l:=0;r:=m+1;
    for i:=1 to m do begin
      readvtx(a,b);readvtx(c,d);
      if a=c then begin
        dec(r);
        if b<d then with cut[r] do begin r1:=a;c1:=b;r2:=c;c2:=d;end
               else with cut[r] do begin r1:=c;c1:=d;r2:=a;c2:=b;end;
      end
      else begin
        inc(l);
        if a<c then with cut[l] do begin r1:=a;c1:=b;r2:=c;c2:=d;end
               else with cut[l] do begin r1:=c;c1:=d;r2:=a;c2:=b;end;
      end;
    end;

    count:=0;
    for i:=1 to n do
      for j:=1 to i do
        go(i,j);
    writeln(count);
  until seekeof;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -