-- 作者:趣题之主
-- 发布时间:11/14/2004 10:59:46 PM
-- 贴一个11.14比赛的1001
抛砖引玉了,大家也把自己AC的程序贴出来分享一下吧~
const oarray[1..3] of string=(\'divine\',\'evil\',\'human\'); type element=record sort:integer; whether:boolean; obj:integer; speaker:integer; end; var statement:array[1..50] of element; num:integer; talked:array[1..5] of integer; ii:array[1..5] of integer; n:integer; flag:boolean; i,j:integer; s:string; speaking:integer; ans:array[1..5] of integer; d:integer; b2,boboolean; begin while not eof do begin fillchar(statement,sizeof(statement),0); fillword(talked,sizeof(talked) div 2,1); num:=0; readln(n); for i:=1 to n do begin readln(s); speaking:=ord(s[1])-ord(\'A\')+1; talked[speaking]:=3; s:=copy(s,3,255); inc(num); statement[num].speaker:=speaking; if (pos(\'It\',s)<>0) then begin with statement[num] do begin if pos(\'day\',s)<>0 then whether:=true else whether:=false; sort:=4; obj:=0; end; continue; end; if (pos(\'I\',s)<>0) then begin with statement[num] do begin obj:=speaking; if pos(\'divine\',s)<>0 then sort:=1; if pos(\'evil\',s)<>0 then sort:=2; if pos(\'human\',s)<>0 then sort:=3; if pos(\'not\',s)<>0 then whether:=false else whether:=true; end; continue; end; with statement[num] do begin obj:=ord(s[1])-ord(\'A\')+1; talked[obj]:=3; if pos(\'divine\',s)<>0 then sort:=1; if pos(\'evil\',s)<>0 then sort:=2; if pos(\'human\',s)<>0 then sort:=3; if pos(\'not\',s)<>0 then whether:=false else whether:=true; end; end; bo=false; b2:=false; for i:=1 to 2 do for ii[1]:=1 to talked[1] do for ii[2]:=1 to talked[2] do for ii[3]:=1 to talked[3] do for ii[4]:=1 to talked[4] do for ii[5]:=1 to talked[5] do begin flag:=true; for j:=1 to num do begin if not flag then break; with statement[j] do begin if obj>=1 then if ((sort<>ii[obj]) and whether) or ((sort=ii[obj]) and not whether) then if (ii[speaker]=1) or ((ii[speaker]=3) and (i=2)) then flag:=false else else if (ii[speaker]=2) or ((ii[speaker]=3) and (i=1)) then flag:=false; if obj=0 then if (whether and (i=1)) or (not whether and (i=2)) then begin if (ii[speaker]=2) or ((ii[speaker]=3) and (i=1)) then flag:=false; end else begin if (ii[speaker]=1) or ((ii[speaker]=3) and (i=2)) then flag:=false; end; end; end; if flag and boo then b2:=true; if flag then begin for j:=1 to 5 do ans[j]:=ii[j]; d:=i; bo=true; end; end; if b2 then writeln(\'Can not determine\'); if not b2 and boo then begin for i:=1 to 5 do if talked=3 then writeln(oo[ans]); if d=1 then writeln(\'day\') else writeln(\'night\'); end; if not boo then writeln(\'Impossible\'); end; end.
|