比赛 |
NOIP2008集训模拟3 |
评测结果 |
WWWWWWWWWW |
题目名称 |
IP网络管理员 |
最终得分 |
0 |
用户昵称 |
zpl123 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-12 10:52:07 |
显示代码纯文本
program networkip;
var
x:array[1..4,1..1000] of integer;
m:integer;
procedure init;
var
i,l,k,code:integer; s1,s:string;
begin
assign(input,'networkip.in');
reset(input);
assign(output,'networkip.out');
rewrite(output);
readln(m);
for i:=1 to m do
begin
readln(s);
l:=length(s);
k:=0;
while (l>0)and(k<=2) do
begin
inc(k);
s1:=copy(s,1,pos('.',s)-1);
val(s1,x[k,i],code);
delete(s,1,pos('.',s));
l:=length(s);
end;
val(s,x[4,i],code);
end;
close(input);
end;
function judge(i1,i2:integer):boolean;
var
k:integer;
begin
judge:=true; k:=1;
while (x[k,i1]=x[k,i2])and(k<=3) do inc(k);
if x[k,i1]<x[k,i2] then judge:=false;
end;
procedure main;
var
i,j,k,p:integer;
t:array[1..4]of integer;
begin
for i:=1 to m-1 do
begin
k:=i;
for j:=i+1 to m do
if (not judge(j,k)) then k:=j;
if k<>i then
for p:=1 to 4 do
begin
t[p]:=x[p,i];
x[p,i]:=x[p,k];
x[p,k]:=t[p];
end;
end;
dec(x[4,1]);
for i:=4 downto 1 do
begin
while x[i,m]<x[i,1] do
begin
x[i,m]:=x[i,m]+256;
dec(x[i-1,m]);
end;
x[i,m]:=255-(x[i,m]-x[i,1]);
end;
end;
procedure print;
var
i:integer;
begin
for i:=1 to 3 do
write(x[i,1],'.');
writeln(x[4,1]);
for i:=1 to 3 do
write(x[i,m],'.');
writeln(x[4,m]);
close(output);
end;
begin
init;
main;
print;
end.