比赛 NOIP2008集训模拟3 评测结果 WWWWWWWWWW
题目名称 IP网络管理员 最终得分 0
用户昵称 EnAsn 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-12 09:45:34
显示代码纯文本
program ex;
type
 ss=array[1..1000,1..4]of integer;
var
 a:ss;
 f1,f2:text;
 m:integer;
procedure init;
 var
  ch:char;
  i,j,code:integer;
  s,s1:string;
  l1,l2:integer;
 begin
  assign(f1,'networkip.in');
  assign(f2,'networkip.out');
  reset(f1);
  rewrite(f2);
  readln(f1,m);
  for i:=1 to m do
   begin
    readln(f1,s);
    for j:=1 to 3 do
     begin
      l2:=pos('.',s);
      s1:=copy(s,1,l2-1);
      val(s1,a[i,j],code);
      delete(s,1,l2);
     end;
    val(s,a[i,j+1],code);
   end;
  close(f1);
 end;
function pd(i,j:integer):boolean;
 var
  k:integer;
 begin
  pd:=false;
  for k:=1 to 4 do
    if a[j,k]<a[i,k] then
     begin
      pd:=true;
      break;
     end;
 end;
procedure sort;
 var
  i,j,t1,t2,t3,t4:integer;
 begin
  for i:=1 to m-1 do
   for j:=i+1 to m do
    if pd(i,j)=true then
     begin
      t1:=a[i,1];t2:=a[i,2];t3:=a[i,3];t4:=a[i,4];
      a[i,1]:=a[j,1];a[i,2]:=a[j,2];a[i,3]:=a[j,3];a[i,4]:=a[j,4];
      a[j,1]:=t1;a[j,2]:=t2;a[j,3]:=t3;a[j,4]:=t4;
     end;
 end;
procedure main;
 var
  i,j,x:integer;
  b:array[1..4]of integer;
 begin
  fillchar(b,sizeof(b),0);
  dec(a[1,4]);
  for i:=1 to 3 do
   write(f2,a[1,i],'.');
  writeln(f2,a[1,4]);
  for i:=4 downto 1 do
   begin
    if a[m,i]<a[1,i] then
     begin
      dec(a[m,i-1]);
      a[m,i]:=a[m,i]+255;
     end;
    b[i]:=255-(a[m,i]-a[1,i]);
   end;
  for i:=1 to 3 do
   write(f2,b[i],'.');
  writeln(f2,b[4]);
 end;
begin
 init;
 sort;
 main;
 close(f2);
end.