比赛 NOIP2008集训模拟3 评测结果 AAWAWAAAAW
题目名称 IP网络管理员 最终得分 70
用户昵称 elysian 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-12 11:02:30
显示代码纯文本
program elysian;
const
fin='networkip.in';fout='networkip.out';
d:array[1..8] of integer=(128,64,32,16,8,4,2,1);
var
f1,f2:text;
c:array[0..1010,1..4,1..8] of integer;
s1,s2:array[1..4,1..8] of integer;
x1,x2:array[1..4] of integer;

m,n:longint;

procedure z2(x,p,q:longint);   //194 1 1
var
i,j,y:longint;
begin
y:=x;
for i:=1 to 8 do
begin
if y-d[i]>=0 then
 begin
  y:=y-d[i];
  c[p,q,i]:=1;
  end;
end;

end;

procedure findn;
var
i,j,k,x:longint;
flag:boolean;
begin
flag:=false;
j:=1;k:=0;
repeat
inc(k);
if (k<=8)and(j<=4) then
begin
x:=c[1,j,k];
for i:=2 to m do
 if c[i,j,k]=x then flag:=false
         else begin flag:=true;break;end;
end;
if k>=9 then begin k:=1;inc(j);end;
until (flag=true)or(j>=5);

n:=(j-1)*8+k-1; //n=3*8+6-1=29
n:=32-n;  //n=3
end;

procedure findip;
var
i,j,t1,t2:longint;
begin
t1:=(32-n) div 8;   // 29 div 8 =3
t2:=8-n;  //8-3=5
for i:=1 to t1 do
 for j:=1 to 8 do
  begin
   s2[i,j]:=1;
   s1[i,j]:=c[1,i,j];
  end;

for j:=1 to t2 do
begin
s2[t1+1,j]:=1;
s1[t1+1,j]:=c[1,t1+1,j]
end;

end;



procedure z10;
var
i,j,x,y,code:longint;
begin
for i:=1 to 4 do
begin
x:=0;y:=0;
 for j:=1 to 8 do
  begin
  x:=x+s1[i,j]*d[j];
  y:=y+s2[i,j]*d[j];
  end;
x1[i]:=x;
x2[i]:=y;
end;
end;

procedure print;
var
i,j:longint;
begin
writeln(f2,x1[1],'.',x1[2],'.',x1[3],'.',x1[4]);
writeln(f2,x2[1],'.',x2[2],'.',x2[3],'.',x2[4]);
end;

procedure init;
var
l1,xx:string;
i,j,x,l,p,code,k:longint;
ch:char;
begin
assign(f1,fin);reset(f1);
assign(f2,fout);rewrite(f2);
readln(f1,m);
for i:=1 to m do
 begin
 p:=0;
 xx:='';
 k:=0;
 readln(f1,l1);
 l:=length(l1);
 for j:=1 to l do
  begin
  ch:=l1[j];
  if ch<>'.' then begin inc(p);insert(ch,xx,p);end
  else
   begin
    inc(k);
    p:=0;
    val(xx,x,code);
    xx:='';
    z2(x,i,k)
   end;
  end;
val(xx,x,code);
z2(x,i,4);
end;
findn;
findip;
z10;
print;


end;

begin
init;
close(f1);
close(f2);
end.