收藏本页
联系我们
论坛帮助

>> 讨论各种网上题库的习题
趣题之家信息学竞赛网上题库 → 贴一个11.14比赛的1001

  发表一个新帖子  发起一个新投票  回复本主题 您是本帖的第 3467 个阅读者
  标题:贴一个11.14比赛的1001 树形   打印   收藏   推荐  
     帅哥哟,离线,有人找我吗?
    
    
    等级:管理员
    威望:50
    文章:291
    积分:669
    注册:2003-05-18
 QQ 给趣题之主发送一个短消息 把趣题之主加入好友 查看趣题之主的个人资料 搜索趣题之主在的所有贴子 点击这里发送电邮给趣题之主 访问趣题之主的主页引用回复这个贴子 回复这个贴子 楼主
发贴心情 贴一个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.

发贴IP已设置保密 2004-11-14 22:59
       
     帅哥哟,离线,有人找我吗?
    
    
    头衔:灵魂亵渎者
    等级:版主
    文章:74
    积分:175
    注册:2004-07-24
给McDsl发送一个短消息 把McDsl加入好友 查看McDsl的个人资料 搜索McDsl在的所有贴子 点击这里发送电邮给McDsl 引用回复这个贴子 回复这个贴子 2
发贴心情
开始做了点,后来没心情了

QQ:317621673
发贴IP已设置保密 2004-11-19 18:08
       

 2   2   1/1页      1    


网上贸易 创造奇迹! 阿里巴巴 Alibaba

Powered By Dvbbs Version 7.1.0
Copyright ©2003 - 2006 QTHome.Org
页面执行时间 00.12500 秒, 3 次数据查询
本论坛采用阿里巴巴支付宝网上银行支付系统,安全、可靠、便捷