记录编号 43123 评测结果 AAAAAAAAAA
题目名称 岛国 最终得分 100
用户昵称 Gravatar天下第一的吃货殿下 是否通过 通过
代码语言 Pascal 运行时间 0.590 s
提交时间 2012-10-07 09:31:16 内存使用 0.26 MiB
显示代码纯文本
var
  a,b,c,d,e,n,zg:longint;
  qq:array[0..5001,1..4] of longint;
  jl:array[0..5000] of longint;
  pdd:array[0..5000] of boolean;
      function pd:boolean;
        var
           i,j,k:longint;
             begin
               if (qq[a,1]>qq[c,3]) or (qq[a,3]<qq[c,1])
                  or (qq[a,2]>qq[c,4]) or (qq[a,4]<qq[c,2])
                    or ((qq[a,1]=qq[c,3]) and (qq[a,2]=qq[c,4]))
                      or ((qq[a,3]=qq[c,1]) and (qq[a,4]=qq[c,2]))
                       or ((qq[a,1]=qq[c,3]) and (qq[a,4]=qq[c,2]))
                         or ((qq[a,3]=qq[c,1]) and (qq[a,2]=qq[c,4]))
                     then exit(false)
                      else exit(true);
      end;
         function find(nn:longint):longint;
             begin
                 if jl[nn]=nn then exit(nn);
                   jl[nn]:=find(jl[nn]);
                   exit(jl[nn]);
      end;
 begin
   assign(input,'jx.in');
   reset(input);
    assign(output,'jx.out');
    rewrite(output);
  readln(n);
   for a:=1 to n do
        begin
            jl[a]:=a;
           for b:=1 to 4 do
             read(qq[a,b]);
              inc(qq[a,3]);
              inc(qq[a,4]);
                for c:=1 to a-1 do
                        if pd=true then begin
                              d:=find(c);
                              jl[d]:=a;
                end;
           end;
    for a:=1 to n do
          begin
             b:=find(a);
                if pdd[b]=false then begin
                   pdd[b]:=true;
                   inc(zg);
                end;
          end;
    writeln(zg);
   close(input);
    close(output);
end.