PersonalCorpus 版 (精华区)
寄信人: sino (蚱蜢舟)
标 题: 1060
发信站: 哈工大紫丁香 (2002年04月06日20:33:23 星期六)
来 源: 202.118.239.224
179327 12:36:01 6 Apr 2002
Bozhang,HIT,P.R.China 1060 Pascal Accepted 0.05 sec 53K
var
s,fin1,fin2:string[16];
i,best_r:integer;
procedure tryit(dep,rnd:integer);
var i,j,k:integer;
begin
if (s=fin1) or (s=fin2) then begin
if rnd<best_r then best_r:=rnd;
exit;
end;
if dep=17 then exit;
tryit(dep+1,rnd);
if s[dep]='b' then s[dep]:='w' else s[dep]:='b';
i:=dep-4;
if (i>0) and (i<17) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep+4;
if (i>0) and (i<17) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep-1;
if (i>0) and (i<17) and ((i-1) div 4 =(dep-1) div 4) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep+1;
if (i>0) and (i<17) and ((i-1) div 4 =(dep-1) div 4) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
tryit(dep+1,rnd+1);
i:=dep-4;
if (i>0) and (i<17) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep+4;
if (i>0) and (i<17) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep-1;
if (i>0) and (i<17) and ((i-1) div 4 =(dep-1) div 4) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
i:=dep+1;
if (i>0) and (i<17) and ((i-1) div 4 =(dep-1) div 4) then begin
if s[i]='b' then s[i]:='w' else s[i]:='b';
end;
if s[dep]='b' then s[dep]:='w' else s[dep]:='b';
end;
begin
fin1:='bbbbbbbbbbbbbbbb';
fin2:='wwwwwwwwwwwwwwww';
s[0]:=chr(16);
for i:=1 to 16 do begin
if eoln(input) then readln;
read(s[i]);
end;
best_r:=17;
tryit(1,0);
if best_r=17 then writeln('Impossible') else writeln(best_r);
end.
--
自笑平生 英气凌云 凛然万里宣城 哪知此际 熊虎途穷来伴麋鹿卑栖
既甘臣妾 犹不许 何为计 争若都燔宝器尽诛吾妻子 径将死战绝雄雌 天意
或怜之 偶闻太宰 正擅权 贪赂市恩私 因将宝玩献诚 虽脱霜戈 石室囚系
忧蹉又经时 恨不如 巢燕 自由归 残月朦胧 寒雨潇潇 有血都成泪 备尝
险厄返邦畿 冤情刻肝脾
董 颖 道宫溥媚(西子词)
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:6.920毫秒