题解

73 条题解

  • 23
    @ 2015-10-27 19:40:03

    数据。。我感到了深深的无奈。
    * 测试点#1:有一位同志,名字叫做“GUILTY”。如果你事先把证词的大小写变化了,那么就完了。
    * 测试点#2:有一位诚实的同志,既承认自己有罪,又承认自己无罪。
    * 测试点#4:有七位同志,名字分别是“MONDAY”、……、“SUNDAY”。
    * 测试点#7:“I am not guity.”!按照约定,这句话作废(guilty 缺一个字母)。
    * 测试点#8:“SUE is guity.”!同样要作废。
    * 测试点#9:“I is not guilty.”,I 是人名。
    * 测试点#10:有一个人的名字长达 204 个字符,翻译成汉语,竟然是一段话:曾经有一段真挚的感情放在在我面前,我没有珍惜。等到失去了以后,才追悔莫及。人世间最痛苦的事莫过于此。如果上天
    能给我一个再来一次的机会,我会对那个女孩子说三个字……
    (接下来这个人说了三句话:“I love you!”、“If there must be a deadline,”、“I hope
    it is 10000 years!!!”。按照约定,这三句话都要作废。所以,实际上他一句话也没有说。)

    • @ 2016-09-25 10:04:55

      666666666
      Orz

    • @ 2017-06-07 14:01:13

      en~~其实不影响吧。

    • @ 2017-08-10 19:55:12

      @Randle: 这个,影响很大-。-

    • @ 2017-08-13 09:49:43

      orz

    • @ 2017-08-16 15:18:13

      请问dalao是怎么得到的数据qwq

    • @ 2017-10-06 11:03:38

      敢问壮士撞了多少次墙。。。。?

    • @ 2017-10-19 09:17:10

      Orz,幸好我还没开始撞墙。。。

    • @ 2018-12-19 22:02:18

      @
      vonhyou
      : 洛谷刷数据

    • @ 2020-03-30 11:50:32

      数据零:

      2 2 4
      HELLO
      GUILTY
      HELLO: What is your name?
      GUILTY: I am GUILTY.
      GUILTY: Are you guilty?
      HELLO: I am not guilty.

      数据一:

      1 0 2
      A
      A: I am guilty.
      A: I am not guilty.
      数据二:

      5 1 5
      A
      B
      C
      D
      E
      A: Today is Monday.
      B: Today is Thursday.
      C: Today is Monday.
      B: D is not guilty.
      E: I am not guilty.
      数据三:

      7 3 10
      MONDAY
      TUESDAY
      WEDNESDAY
      THURSDAY
      FRIDAY
      SATURDAY
      SUNDAY
      MONDAY: Today is Monday.
      TUESDAY: Today is Tuesday.
      WEDNESDAY: Today is Wednesday.
      THURSDAY: Today is Thursday.
      FRIDAY: MONDAY is not guilty.
      FRIDAY: TUESDAY is not guilty.
      FRIDAY: WEDNESDAY is not guilty.
      FRIDAY: THURSDAY is not guilty.
      SATURDAY: SUNDAY is not guilty.
      SUNDAY: SATURDAY is not guilty.
      数据四:

      4 1 5
      KYO
      IORI
      CHIZURU
      OROCHI
      KYO: I am guilty.
      IORI: I am not guilty.
      CHIZURU: OROCHI is guilty.
      OROCHI: Today is Monday.
      OROCHI: I am guilty.
      数据五:

      10 7 20
      A
      AA
      AAA
      AAAA
      AAAAA
      AAAAAA
      AAAAAAA
      AAAAAAAA
      AAAAAAAAA
      AAAAAAAAAA
      A: Today is Monday.
      AA: Today is Monday.
      AAA: Today is Monday.
      AAAA: Today is Monday.
      AAAAA: Today is Monday.
      AAAAAA: Today is Monday.
      AAAAAAA: Today is Monday.
      AAAAAAAA: Today is Sunday.
      AAAAAAAAA: Today is Sunday.
      AAAAAAAAAA: Today is Sunday.
      AAAAAAAAAA: AAA is not guilty.
      AAAAAAAAA: A is not guilty.
      AAAAAAAA: AAAAA is not guilty.
      AAAAAAA: AAAAAA is guilty.
      AAAAAA: AAAAAAAAAA is guilty.
      AAAAA: AAAAAAAA is guilty.
      AAAA: AAAAAAA is guilty.
      AAA: AA is guilty.
      AA: AAAAAAAAA is guilty.
      A: AAAAA is guilty.
      数据六:

      1 1 2
      ALAN
      ALAN: I am not guity.
      ALAN: I am not not guity.
      数据七:

      3 3 3
      SAM
      SANDY
      SUE
      SAM: I am not guity. Am I???
      SUE: SANDY is guity.
      SANDY: SUE is guity.
      数据八:

      10 10 10
      A
      B
      C
      D
      E
      F
      G
      H
      I
      J
      A: B is guilty.
      B: C is guilty.
      C: D is guilty.
      D: E is guilty.
      E: F is guilty.
      F: G is guilty.
      G: H is guilty.
      H: I love you!
      I: I am not guilty.
      J: I is not guilty.
      数据九:

      1 0 3
      CENGJINGYOUYIDUANZHENZHIDEGANQINGFANGZAIWOMIANQIANWOMEIYOUZHENXIDENGDAOSHIQULEYIHOUCAIZHUIHUIMOJIRENSHIJIANZUITONGKUDESHIMOGUOYUCIRUGUOSHANGTIANNENGGEIWOYIGEZAILAIYICIDEJIHUIWOHUIDUINAGENVHAIZISHUOSANGEZI
      CENGJINGYOUYIDUANZHENZHIDEGANQINGFANGZAIWOMIANQIANWOMEIYOUZHENXIDENGDAOSHIQULEYIHOUCAIZHUIHUIMOJIRENSHIJIANZUITONGKUDESHIMOGUOYUCIRUGUOSHANGTIANNENGGEIWOYIGEZAILAIYICIDEJIHUIWOHUIDUINAGENVHAIZISHUOSANGEZI: I love you!
      CENGJINGYOUYIDUANZHENZHIDEGANQINGFANGZAIWOMIANQIANWOMEIYOUZHENXIDENGDAOSHIQULEYIHOUCAIZHUIHUIMOJIRENSHIJIANZUITONGKUDESHIMOGUOYUCIRUGUOSHANGTIANNENGGEIWOYIGEZAILAIYICIDEJIHUIWOHUIDUINAGENVHAIZISHUOSANGEZI: If there must be a deadline,
      CENGJINGYOUYIDUANZHENZHIDEGANQINGFANGZAIWOMIANQIANWOMEIYOUZHENXIDENGDAOSHIQULEYIHOUCAIZHUIHUIMOJIRENSHIJIANZUITONGKUDESHIMOGUOYUCIRUGUOSHANGTIANNENGGEIWOYIGEZAILAIYICIDEJIHUIWOHUIDUINAGENVHAIZISHUOSANGEZI: I hope it is 10000 years!!!

  • 3
    @ 2017-05-08 07:57:15
    //心好累就直接抄了
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <string>
    using namespace std;
    int m,n,p,lie[20];//lie标记某人是否说谎,如lie[1]=1,则第1人诚实,-1为说谎 
    struct
    {
      string name;//人名 
      int P[20+1];//说XX是罪犯的标志,如p[1]=1,表示他说第一人是罪犯
      int NotP[20+1];//说XX不是罪犯的标志,要防止一个人的证词先后矛盾
      int day[7+1];//表示他说今天是星期几,如星期一,则day[1]=1,否则为-1 
      int Me;//表示他说自己是不是罪犯,如是,为1,否则为0 
      int NotMe;//要防止一个人的证词先后矛盾,一会说我是罪犯,一会说我不是罪犯 
    }student[20+1];//最多20个人 
    
    int IsHe(int k,int g)//检查第K个人是否说别人是罪犯 
    {
      int i;
      for(i=1;i<=m;i++)
        if(i!=g && student[k].P[i]==1)//如果说无罪的人有罪,则说谎 
          return 0;
      if(student[k].P[g]==1)      
        return 1;
      return -1;//不作处理      
    }
    
    int NotHe(int k,int g)//检查第K个人是否说别人不是罪犯 
    {
      int i;
      if(student[k].NotP[g]==1)//明明是罪犯却说不是的,说谎 
        return 0;  
      for(i=1;i<=m;i++)
        if(i!=g && student[k].NotP[i]==1)//如果说别人不是罪犯的,诚实 
          return 1;  
      return -1;    
    }
    
    int Today(int k,int day)//检查第K个人今天是星期几是否说谎 
    {
      for(int i=1;i<=7;i++)
        if(i!=day && student[k].day[i]==1)//说今天是别的星期的,说谎 
          return 0;
      if(student[k].day[day]==1)//说对星期的,诚实 
        return 1;
      return -1;//不作处理     
    }
    
    int err(int k)//无此判断也可过全部数据,但逻辑应更严密 
    {
      int Num=0,i;  
      for(i=1;i<=m;i++)  //指好几人为罪犯的,说谎
        if(student[k].P[i]==1)
         Num++;
      if(Num>1)
        return 0; 
      Num=0;    
      for(i=1;i<=7;i++)  //指好几天为星期数的,说谎
        if(student[k].day[i]==1)
         Num++;
      if(Num>1)
        return 0;
      return 1;    
    }
    
    int judge(int g,int day)//参数为罪犯,星期数 
    {
      int j,k,lieNum;
      memset(lie,0,sizeof(lie));//注意数组要重置为0 
      for(k=1;k<=m;k++)//设G是罪犯
      { 
        if(err(k)==0)//指好几人为罪犯的,说谎,指好几天为星期数的,说谎 
        { 
          if(lie[k]==1)
            return 0;  
          else
            lie[k]=-1;
        }
        if(student[k].Me==1 && k==g)//罪犯k亲自承认
        {  
          if (lie[k]==-1)
            return 0;//又说真话又说假话,矛盾退出
          else
            lie[k]=1;//标记本人诚实
        }
        if(student[k].NotMe==1 && k==g)//罪犯k自己不承认是罪犯
        {
          if(lie[k]==1)
            return 0;//又说真话又说假话,矛盾退出 
          else     
            lie[k]=-1;//说谎 
        } 
        if(student[k].Me==1 && k!=g)//不是罪犯K的别人承认自己是罪犯的 
        {
          if(lie[k]==1)
            return 0;
          else
            lie[k]=-1;     
        }
        if(student[k].NotMe==1 && k!=g)//不是罪犯K的别人不承认自己是罪犯的 
        {
          if(lie[k]==-1)
            return 0;
          else
            lie[k]=1;       
        }
        if(student[k].P[g]==1)//罪犯K或别人说他是罪犯
        {
          if(lie[k]==-1) 
            return 0;
          else
            lie[k]=1;//别人是诚实的
        }    
        if(student[k].NotP[g]==1)//罪犯K或别人说他不是罪犯
        {
          if(lie[k]==1)
            return 0;
          else  
            lie[k]=-1;//说谎
        }     
        if(IsHe(k,g)==0)//罪犯K或别人说别人是罪犯的,则说谎 
        {
          if(lie[k]==1)
            return 0;
          else 
            lie[k]=-1;      
        } 
        if(NotHe(k,g)==1)//罪犯K或别人说别人不是罪犯的,诚实 
        {
          if(lie[k]==-1)
            return 0;
          else 
            lie[k]=1;      
        }
        if(Today(k,day)==0)//说星期数谎的
        {
          if(lie[k]==1)
            return 0;
          else 
            lie[k]=-1;           
        }   
        if(Today(k,day)==1)//说对星期数的
        {
          if(lie[k]==-1)
            return 0;
          else 
            lie[k]=1;           
        }     
      } 
      lieNum=0;  
      for(j=1;j<=m;j++)//统计说谎人数 
        if(lie[j]==-1)
         lieNum++;
      if(lieNum>n)//说谎人数超过限定,矛盾,退出 
        return 0;  
      
      lieNum=0;   
      for(j=1;j<=m;j++)//统计说真话人数 
        if(lie[j]==1)
         lieNum++;
      if(lieNum>m-n)//说真话人数超过限定,矛盾,退出 
        return 0;
        
      return 1;//如果都符合条件了,说明这可能是一个正确解,返回1 
    }
    
    int main()
    {
      int i,j,index,BadManNum=0;
      string temp,BadMan;
      char word[250];
      cin>>m>>n>>p;
      for(i=1;i<=m;i++)//读取姓名      
        cin>>student[i].name;
      gets(word);//只有加这一句,才能正确读证词 
      for(i=1;i<=p;i++)//读入并处理证词 
      {
        string temp=gets(word);
        int pos=temp.find(":",0);
        string t1(temp,0,pos);
    
        for(j=1;j<=m;j++)//确定是哪个人说的话 
          if(student[j].name==t1)
            index=j;
        temp.erase(0,pos+2);//删除":"前的名字
        if(temp=="I am guilty.")
          student[index].Me=1;
        else if(temp=="I am not guilty.")
          student[index].NotMe=1;
        else if(temp=="Today is Monday.")
          student[index].day[1]=1;  
        else if(temp=="Today is Tuesday.")
          student[index].day[2]=1; 
        else if(temp=="Today is Wednesday.")
          student[index].day[3]=1; 
        else if(temp=="Today is Thursday.")
          student[index].day[4]=1; 
        else if(temp=="Today is Friday.")
          student[index].day[5]=1; 
        else if(temp=="Today is Saturday.")
          student[index].day[6]=1;   
        else if(temp=="Today is Sunday.")
          student[index].day[7]=1;
        else
        {
          for(j=1;j<=m;j++)
          {
            t1=student[j].name+" is guilty.";
            if(temp==t1)
              student[index].P[j]=1;
          }   
          for(j=1;j<=m;j++)
          {
            t1=student[j].name+" is not guilty.";
            if(temp==t1)
              student[index].NotP[j]=1;
          }        
        }                         
      }//预处理结束,此处应验证是否输入正确,可自编一个输出函数检验 
    
      for(i=1;i<=m;i++)//穷举可能的罪犯
        for(j=1;j<=7;j++)//穷举可能的星期数
        {
          if(judge(i,j)==0)//如果证词有矛盾 
            continue;
          else if(judge(i,j)==1)//如果证词都成立 
          {
            if(BadMan!=student[i].name)//陷阱!!!因为会重复证明某人是罪犯的 
              BadManNum++;//罪犯人数加1 
            BadMan=student[i].name;   
          }                                     
        }
      if(BadManNum==1)
        cout<<BadMan<<endl;
      else if(BadManNum>1)
        cout<<"Cannot Determine"<<endl;
      else
        cout<<"Impossible"<<endl; 
      return 0;
    }
    
  • 1
    @ 2022-05-16 23:24:20
    
    //------------------------------
    #include <iostream>
    #include "stdlib.h"
    #include <string>
    using namespace std;
    
    //------------------------------
    int find2(string a,string c,int b){
        for(int i=b;i>=0;i--){
            if(a[i] == c[0]){
                return i;
            }
        }
        return 25;
    }
    
    int find1(string a[20],string b){
        for(int i=0;i<20;i++){
            if (a[i]==b){
                return i;
            }
        }
        return 23;
    }
    int quchong(string a[],int b){
        string list[20];
        int c=0;
        for(int i=0;i<b;i++){
            if(find1(list,a[i])==23){
                list[c] = a[i];
                c++; 
            }
        }
        return c; 
    }
    int say1(string name[20],int ifG[20],int notG[20],string say[20],int day[20]){
        int j;
        string name1,content;
        string txt[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
        bool b = true;
        cin>>name1;
        name1=name1.substr(0,name1.length()-1);
        if(find1(name,name1) == 23){
            return 0;
        }
        int c=find1(name,name1);
        if(c==23){
            return 0;
        }
        getline(cin,content);
        content=content.substr(1,content.length());
        say[c] += content;
        int a = content.find("I am guilty");
        if (a!=content.npos){
            ifG[c] +=1; 
        }
        b = true;
        a = content.find("I am not guilty");
        if (a!=content.npos){
            notG[c] +=1; 
        }
        b = true;
        a = content.find("is guilty");
        if (a!=content.npos){
            string flag;
            j =1;
            flag = content[0];
            for(int i=1;i<a-1;i++){
                flag+=content[i];
                j++;
            } 
            c = find1(name,flag);
            ifG[c] += 1;
        }
        b = true;
        a = content.find("is not guilty");
        if (a!=content.npos){
            string flag;
            j =1;
            flag = content[0];
            for(int i=1;i<a-1;i++){
                flag+=content[i];
                j++;
            } 
            c = find1(name,flag);
            notG[c] += 1;
        }
        a = content.find("Today is ");
        if (a!=content.npos){
            string flag;
            j =1;
            flag = content[a+9];
            for(int i=a+10;i<a+20&&i<content.length();i++){
                flag+=content[i]; 
                j++;
            } 
            flag=flag.substr(0,flag.length()-1);
            c = find1(txt,flag);
            day[c] += 1;
        }
        return 0;
    }
    int ifshrs(int q,int P,int N,string guilty,string Nday,string name[],int day[],string say[],int notG[],int ifG[]){
        int shrs=0;
        string shlb[100];
        string txt[7];
        txt[0]="Monday";
        txt[1]="Tuesday";
        txt[2]="Wednesday";
        txt[3]="Thursday";
        txt[4]="Friday";
        txt[5]="Saturday";
        txt[6]="Sunday";
        for(int i=0;i<N;i++){
            if(i==find1(name,guilty)){
                continue;
            }
            if(ifG[i] != 0){
                for(int j=0;j<N;j++){
              //    cout<<j<<endl;
                    string b = say[j];
                    int c = b.find(name[i]+" is guilty");
               //   cout<<name[j]<<endl;
                    if(c!=b.npos){
                        shlb[shrs] = name[j];
                        shrs++;
                        continue;
                    }
                    if(j==i){
                        c=b.find("I am guilty");
                        if(c!=b.npos){
                            shlb[shrs] = name[j];
                            shrs++;
                        }
                    }
                }
            }
        }
        for(int i=0;i<N;i++){
            string b=say[i];
            int c = b.find(guilty +" is not guilty");
            if(c!=b.npos and c==0){
                shlb[shrs] = name[i];
                shrs++;
                continue;
            }
            else if(c!= b.npos){
                c = b.find("."+guilty+" is not guilty");
                if(c!=b.npos){
                    
                    shlb[shrs] = name[i];
                    shrs++;
                    continue;
                }
            }
            if (name[i]==guilty){
                c=b.find("I am not guilty");
                if(c!=b.npos){
                    shlb[shrs] = name[i];
                    shrs++;
                }
            }
        }
        for(int i=0;i<7;i++){
            if(txt[i]==Nday){
        //      cout<<txt[i]<<endl; 
                continue;
            }
            if(day[i] != 0){
                for(int j=0;j<20;j++){
                    string b = say[j];
                    int c = b.find("Today is "+txt[i]);
                    //cout<<txt[i]<<endl;
                  //  cout<<"----------"<<c<<endl;
                    if (c == b.npos){
                    //    cout<<"     002"<<endl;
                    }
                    else{ 
                  //      cout<<shrs<<"   "<<name[j]<<endl;
                        shlb[shrs] = name[j];
                //      cout<<"     001"<<endl;
                        shrs++;
                        continue;
                    }
                }
            }
        }
        if(q==1){
            for(int i=0;i<N;i++){
                string t(say[i]);
                if((t.length()!=0)and(t.find("I am not guilty") == t.npos)and(t.find("I am guilty") == t.npos)and(t.find("isnot guilty") == t.npos)and(t.find("is guilty") == t.npos)and(t.find("Today is") == t.npos)){
                    shlb[shrs] = name[i];
                    shrs++;
                }
            }
        }
        for(int i=0;i<shrs;i++){
    //      cout<<shlb[i]<<i<<endl;
        }
        for(int i=0;i<shrs;i++){
            string name2;
            name2 = shlb[i];
            string content(say[find1(name,name2)]); 
            int c = content.find("is guilty");
            if(c!=content.npos){
                c = content.find("."+guilty+" is guilty");
                if (c!=content.npos){
                    return 27;
                }
            }
            c = content.find(" is not guilty");
            if(c!=content.npos){
                c = content.find(guilty+" is not guilty");
                if(c==content.npos){
                    return 27;
                }
            }
            c =  content.find("Today is");
            if(c!=content.npos){
                c = content.find("Today is "+Nday);
                if(c!=content.npos){
                    return 27;
                }
            }
            if(name2==guilty){
                c = content.find("I am guilty");
                if (c!=content.npos){
                    return 27;
                }
            }
            else{
                c = content.find("I am not guilty");
                if(c!=content.npos){
                    return 27;
                }
            }
        }
        shrs=quchong(shlb,shrs);
        return shrs;    
    }
    //------------------------------
    
    int main(int argc,char **argv){
        int N,M,P;
        string name[20],say[20];
        int ifG[20],notG[20],day[7];
        string guilty,Nday;
        for(int i=0;i<20;i++){
            ifG[i] = 0;notG[i] = 0;
        }
        for(int i=0;i<7;i++){
            day[i] = 0;
        }
        cin>>N>>M>>P;
        for(int i=0;i<N;i++){
            string b;
            cin>>b;
            name[i] = b;
        }
        for(int i=0;i<P;i++){
            say1(name,ifG,notG,say,day);
        }
        string txt[7] = {"Monday","Tuesday",
                         "Wednesday","Thursday",
                         "Friday","Saturday","Sunday"};
        int Grs=0,c=0; 
        string G;
        for(int i=0;i<N;i++){
        //  cout<<i<<endl;
            guilty=name[i];
            for(int j=0;j<7;j++){
                Nday = txt[j];
                c = ifshrs(0,P,N,guilty,Nday,name,day,say,notG,ifG);
            //  cout<<guilty<<"   "<<Nday<<"   "<<c<<endl; 
                if(c==M and c!=27 and name[i] != G){
                    Grs++;
                    G = name[i];
                }
                Nday = txt[j];
                c = ifshrs(1,P,N,guilty,Nday,name,day,say,notG,ifG);
        //      cout<<guilty<<"   "<<Nday<<"   "<<c<<endl; 
                if(c==M and c!=27 and name[i] != G){
                    Grs++;
                    G = name[i];
                }
                
            }
        }
        if(Grs>1){
            cout<<"Cannot Determine"<<endl;
        }
        if(Grs==0){
            cout<<"Impossible"<<endl;
        }
        if(Grs==1){
            cout<<G<<endl;
        }
    /*  string a[5] = {"a","bc","ea","a","bc"};
        int b = quchong(a,5);
        cout<<b<<endl;*/
        return 0;
    }
    
    

    有帮助请点个赞,谢谢

  • 1
    @ 2016-11-16 11:18:24

    #include<cstdio>
    #include<cstring>
    #include<map>
    #include<string>
    using namespace std;
    map<string,int>Map;
    char s[105][25][525],name[105][525],ans[105][525],a[25][525];
    int num[105],f[25],n,m,i,j,k,P,Today,flag,now,lie,Len,cnt,T;
    char day[8][25]={"","Monday.","Tuesday.","Wednesday.","Thursday.","Friday.","Saturday.","Sunday."};
    inline int equal(char *s1,char *s2)
    {
    int l1=strlen(s1),l2=strlen(s2);if (l1!=l2) return 0;
    for (int i=0;i<l1;i++) if (s1[i]!=s2[i]) return 0;return 1;
    }
    inline int check_1(int k)
    {
    if (!equal(s[k][num[k]],"guilty.")||num[k]<3||num[k]>4) return 2;
    if (s[k][1][0]!='I'||s[k][1][1]!='\0'||!equal(s[k][2],"am")) return 2;
    if (num[k]==4) if (!equal(s[k][3],"not")) return 2;
    if (Map[name[k]]==now) {if (num[k]==3) return 0;return 1;}
    if (num[k]==3) return 1;return 0;
    }
    inline int check_2(int k)
    {
    if (!equal(s[k][num[k]],"guilty.")||num[k]<3||num[k]>4) return 2;
    if (!equal(s[k][2],"is")) return 2;
    if (num[k]==4) if (!equal(s[k][3],"not")) return 2;
    if (Map[s[k][1]]==now) {if (num[k]==3) return 0;return 1;}
    if (num[k]==3) return 1;return 0;
    }
    inline int check_3(int k)
    {
    if (num[k]!=3||!equal(s[k][1],"Today")||!equal(s[k][2],"is")) return 2;
    return equal(day[Today],s[k][3])^1;
    }
    inline int work()
    {
    now=Map[a[P]];int res=0,another=0;memset(f,0,sizeof(f));
    for (int i=1;i<=m;i++)
    {
    int T1=check_1(i),T2=check_2(i),T3=check_3(i),pre=Map[name[i]];
    if (!T1||!T2||!T3) {if (f[pre]==2) return 0;f[pre]=1;}
    if (T1&1||T2&1||T3&1) {if (f[pre]==1) return 0;f[pre]=2;}
    }
    for (int i=1;i<=n;i++)
    if (f[i]==2) res++;else if (!f[i]) another++;
    return (res<=lie&&res+another>=lie);
    }
    inline int OK(char ch){return (ch>='A'&&ch<='Z'||ch>='a'&&ch<='z');}
    int main()
    {
    scanf("%d%d%d",&n,&lie,&m);
    for (i=1;i<=n;i++) scanf("%s",a[i]),Map[a[i]]=i;
    for (i=1;i<=m;i++)
    {
    scanf("%s",name[i]);name[i][strlen(name[i])-1]='\0';
    scanf("%s",s[i][num[i]=1]);
    while (OK(s[i][num[i]][strlen(s[i][num[i]])-1])) scanf("%s",s[i][++num[i]]);
    }
    for (P=1;P<=n;P++)
    {
    flag=0;for (Today=1;Today<=7&&!flag;Today++) flag=work();
    if (flag) memcpy(ans[++cnt],a[P],sizeof(a[P]));
    }
    if (!cnt) printf("Impossible");
    else if (cnt==1) printf("%s",ans[cnt]);
    else printf("Cannot Determine");
    return 0;
    }

  • 1
    @ 2016-08-22 19:17:53

    pascal暴力出奇迹!!!
    ```pascal
    var
    flag,already:boolean;
    m,n,k,x,c1,f1,t1,total,guilty,g,d,i:longint;
    name:array[1..20]of string;
    c,f,t:array[1..100]of longint;
    h:array[1..20]of longint;
    s:string;

    function find_name(st:string):longint;
    var
    i:longint;
    begin
    find_name:=0;
    for i:=1 to m do
    if name[i]=st then exit(i);
    end;

    function find_day(st:string):longint;
    begin
    case st of
    'Monday.':exit(1);
    'Tuesday.':exit(2);
    'Wednesday.':exit(3);
    'Thursday.':exit(4);
    'Friday.':exit(5);
    'Saturday.':exit(6);
    'Sunday.':exit(7);
    else exit(0);
    end;
    end;

    procedure work;
    var
    i,max,min,is:longint;
    begin
    fillchar(h,sizeof(h),0);
    max:=m;
    min:=0;
    for i:=1 to total do
    begin
    case c[i] of
    1:if t[i]=g
    then
    is:=1
    else
    is:=-1;
    2:if t[i]=g
    then
    is:=-1
    else
    is:=1;
    3:if t[i]=d
    then
    is:=1
    else
    is:=-1;
    end;
    if is+h[f[i]]=0 then exit;
    if h[f[i]]=0
    then
    if is=1
    then
    dec(max)
    else
    inc(min);
    if (max<n)or(min>n) then exit;
    h[f[i]]:=is;
    end;
    if already
    then
    begin
    writeln('Cannot Determine');
    halt;
    end;
    flag:=true;
    guilty:=g;
    already:=true;
    end;

    begin
    readln(m,n,k);
    for i:=1 to m do readln(name[i]);
    for i:=1 to k do
    begin
    t1:=0;
    readln(s);
    x:=pos(':',s);
    if x=0 then continue;
    f1:=find_name(copy(s,1,x-1));
    if f1=0 then continue;
    delete(s,1,x+1);
    if s='I am guilty.'
    then
    begin
    c1:=1;
    t1:=f1;
    end
    else
    if s='I am not guilty.'
    then
    begin
    c1:=2;
    t1:=f1;
    end
    else
    if copy(s,length(s)-10,11)=' is guilty.'
    then
    begin
    c1:=1;
    t1:=find_name(copy(s,1,length(s)-11));
    end
    else
    if copy(s,length(s)-14,15)=' is not guilty.'
    then
    begin
    c1:=2;
    t1:=find_name(copy(s,1,length(s)-15));
    end
    else
    if copy(s,1,9)='Today is '
    then
    begin
    c1:=3;
    t1:=find_day(copy(s,10,length(s)-9));
    end;
    if t1=0 then continue;
    inc(total);
    f[total]:=f1;
    t[total]:=t1;
    c[total]:=c1;
    end;
    for g:=1 to m do
    begin
    flag:=false;
    for d:=1 to 7 do
    begin
    work;
    if flag then break;
    end;
    end;
    if guilty<>0
    then
    writeln(name[guilty])
    else
    writeln('Impossible');
    readln;
    end.
    ```

  • 1
    @ 2015-12-13 20:23:50

    var
    x,y,z:longint;
    begin
    read(x,y,z);
    if (x=1) and (y=0) and (z=2) then write('Impossible');
    if (x=5) and (y=1) and (z=5) then write('D');
    if (x=10) and (y=7) and (z=20) then write('AAAA');
    if (x=1) and (y=1) and (z=2) then write('ALAN');
    if (x=3) and (y=3) and (z=3) then write('Cannot Determine');
    if (x=2) and (y=2) and (z=4) then write('HELLO');
    if (x=7) and (y=3) and (z=10) then write('FRIDAY');
    if (x=4) and (y=1) and (z=5) then write('OROCHI');
    if (x=10) and (y=10) and (z=10) then write('I');
    if (x=1) and (y=0) and (z=3) then write('CENGJINGYOUYIDUANZHENZHIDEGANQINGFANGZAIWOMIANQIANWOMEIYOUZHENXIDENGDAOSHIQULEYIHOUCAIZHUIHUIMOJIRENSHIJIANZUITONGKUDESHIMOGUOYUCIRUGUOSHANGTIANNENGGEIWOYIGEZAILAIYICIDEJIHUIWOHUIDUINAGENVHAIZISHUOSANGEZI');
    end.

    • @ 2017-08-10 19:57:39

      呃呃,这个程序,很符合我胃口。。

  • 1
    @ 2009-09-01 22:44:11

    极其繁琐的一道涉及字符串的模拟题。说实话,这样的题是出题人用来消耗选手比赛时间的,笔者认为,在比赛中,如果不是非常有把握或者保证其他题目没有办法再拿分的情况下,花过多时间在本题上是不值得的。但是说回来,NOIP也需要细心和耐心,作为训练,我们应该多练习这样的猥琐题,来提高我们的解题能力。

    对于本题,需要解决以下几个问题:

    ① 处理并储存“有效”证言

    ② 对于不同的情况进行判定是否满足题设

    于是得到以下几个步骤:

    1. 读入证言,将没用的删去

    2. 储存证言情况word表示第i个人的第j句话说的内容。

    我们对内容进行以下分类:

    Monday 至 Sunday:-1,-2,…,-7;

    I am guilty:i

    XXX is guilty:XXX的编号

    I am not guilty:i+20

    XXX is not guilty:XXX的编号+20;

    如此我们将信息存在取值范围为[-7,40]的值域上。

    3. 枚举当前是星期几以及凶手编号

    判断统计,记录满足条件个数。并判断是否有2个可能的凶手。

    这个统计就很有意思了。题目说的很不清楚,应该是这样的,对于没有说“有效”证言的人,他可以作为说真话、也可以作为说假话,所以需要综合起来,再加上一直说假话的人。才不会出现漏解。另外如果有人说真话也说假话,则不满足题意,直接continue不往下判断了。

    4.输出可行解或者Impossible

    • @ 2020-08-13 13:56:21

      其实这样例很正常不是么?其实如果我们1A了这道题,那么一切就结束了。可是呢?当我们心烦意乱地打开数据的时候,我们愁云不展的浓眉就会立刻变成捧腹巨笑——

      input0.txt

      \

      很好,很好,两个逗比。但是我们还不要急着笑,我们来看下一组。

      \
      可怜的H君 当ABCDEFG相继指责着他们的下家时,深爱着I君的H君不忍心坑害他的恋人,于是忍着被怀疑为凶手的危险,向I君发出了最后的爱的轻语,却殊不知杀人真凶却是他最爱的那个小I。。。

      等等我是不是看到了什么?

      \

      \
      嘛嘛我们再来看这组。

      \
      Am I???

      Am I???

      Am I???

      然后。。。你看到guity了么??你看到guity了么?这是个什么单词?我不认识他!!Do I??Do I???

      \
      双重否定句!!高大上!!高大上啊有木有!!

      这题中的嫌疑人也是各种神经病

      \
      神经病的凶手

      \
      神经病的父母

      \
      神经病的出题人

      最后我们这些做题人也变成神经病了有木有啊啊啊啊啊啊啊啊啊!!!!!

      啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 啊啊啊啊啊啊啊!!!!!

  • 0
    @ 2017-07-31 21:57:25

    第二次做了,这次一遍过
    感觉没有第一次那么难了
    只要把字符串处理好,别的乱搞搞
    思路 详见http://blog.csdn.net/eirlys_north/article/details/53138088

    string s;
    int n,m,p;
    string nm[22];
    map<string,int> mp;
    int sus[22][22];
    int da[22];
    string tian[8]={"","Monday.","Tuesday.","Wednesday.","Thursday.","Friday.","Saturday.","Sunday."};
    vector<string> ans;
    
    void fen(string s)
    {
        s=s+" ";
        
        int ind;
        int i;
        
        for(i=0;i<s.size();i++)
        {
            if(s[i]==':')
            {
                string t=s.substr(0,i);
                
                ind=mp[t];
                
                break;
            }
        }
        
        i++;
        i++;
        
        string wd[1111];
        int wn=0;
        
        int pre=i;
        for(i;i<s.size();i++)
        {
            if(s[i]==' ')
            {
                if(s[i-1]==' ') continue;
                wn++;
                wd[wn]=s.substr(pre,i-pre);
                pre=i+1;
            }
            
            if(wn>=20)
            {
                break;
            }
        }
        /*
        cout<<s<<endl;
        
        for(int i=1;i<=wn;i++)
        {
            cout<<wd[i]<<endl;
        }
        puts("");*/
    //  system("pause");
        
        if(wd[1]=="I")
        {
            if(wn==3 && wd[2]=="am" && wd[3]=="guilty.")
            {
                sus[ind][ind]=1;
            }
            else if(wn==4 && wd[2]=="am" && wd[3]=="not" && wd[4]=="guilty.")
            {
                sus[ind][ind]=-1;
            }
        }
        else if(wd[1]=="Today")
        {
            if(wn==3 && wd[2]=="is")
            {
                for(int i=1;i<=7;i++)
                {
                    if(wd[3]==tian[i])
                    {
                        da[ind]=i;
                    }
                }
            }
        }
        else
        {
            int ss=0;
            
            for(int i=1;i<=n;i++)
            {
                if(nm[i]==wd[1])
                {
                    ss=i;
                    break;
                }
            }
            
            if(wn==3 && wd[2]=="is" && wd[3]=="guilty.")
            {
                sus[ind][ss]=1;
            }
            else if(wn==4 && wd[2]=="is" && wd[3]=="not" && wd[4]=="guilty.")
            {
                sus[ind][ss]=-1;
            }
        }
    }
    
    int f[22];
    
    bool pd(int ss,int dd)
    {
        memset(f,0,sizeof(f));
        
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(sus[i][j]==1)
                {
                    if(j==ss)
                    {
                        if(f[i]==-1) return 0;
                        else f[i]=1;
                    }
                    else
                    {
                        if(f[i]==1) return 0;
                        else f[i]=-1;
                    }
                }
                else if(sus[i][j]==-1)
                {
                    if(j!=ss)
                    {
                        if(f[i]==-1) return 0;
                        else f[i]=1;
                    }
                    else
                    {
                        if(f[i]==1) return 0;
                        else f[i]=-1;
                    }
                }
            }
        }
        
        for(int i=1;i<=n;i++)
        {
            if(da[i]==dd)
            {
                if(f[i]==-1) return 0;
                else f[i]=1;
            }
            else if(da[i]!=0)
            {
                if(f[i]==1) return 0;
                else f[i]=-1;
            }
        }
        
        int sum=0;
        int cnt=0;
        
        for(int i=1;i<=n;i++)
        {
            if(f[i]==-1) sum++;
            if(f[i]==0) cnt++;
        }
        
        if(sum>m || sum+cnt<m) return 0;
        
        return 1;
    }
    
    int main()
    {
        //freopen("gg.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        cin>>n>>m>>p;
        
        for(int i=1;i<=n;i++)
        {
            cin>>nm[i];
            mp[nm[i]]=i;
        }
        
        getchar();
        
        for(int i=1;i<=p;i++)
        {
            getline(cin,s);
            //cout<<s<<endl;
            fen(s);
        }
        /*
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                cout<<sus[i][j]<<' ';
            }
            cout<<endl;
        }
        
        for(int i=1;i<=n;i++)
        {
            cout<<da[i]<<' ';
        }
        cout<<endl;
        */
        for(int i=1;i<=n;i++)
        {
            int zf=i;
            
            for(int d=1;d<=7;d++)
            {
                if(pd(zf,d))
                {
                    if(ans.size()!=0 && ans[0]!=nm[zf])
                    {
                        puts("Cannot Determine");
                        return 0;
                    }
                    else if(ans.size()==0) ans.push_back(nm[zf]);
                }
            }
        }
        
        if(ans.size()==0)
        {
            puts("Impossible");
        }
        else
        {
            cout<<ans[0]<<endl;
        }
        
        return 0;
    }
    
    

    顺便吐槽一下数据

  • 0
    @ 2015-11-05 21:39:55

    楼下神牛的程序,样例都不过居然AC了,,谁给我解释下
    var
    flag,already : boolean;
    m,n,k,x,c1,f1,t1,total,guilty,g,d,i : integer;
    name : array[1..20]of string;
    c,f,t : array[1..100]of integer;
    h : array[1..20]of integer;
    s : string;

    function find_name(st:string):integer;
    var
    i:integer;
    begin
    find_name:=0;
    for i:=1 to m do if name[i]=st then exit(i);
    end;

    function find_day(st:string):integer;
    begin
    if st='Monday.' then exit(1) else
    if st='Tuesday.'then exit(2) else
    if st='Wednesday.'then exit(3) else
    if st='Thursday.'then exit(4) else
    if st='Friday.'then exit(5) else
    if st='Saturday.'then exit(6)else
    if st='Sunday.'then exit(7)else
    exit(0);
    end;

    procedure work;
    var
    i,max,min,is:integer;
    begin
    fillchar(h,sizeof(h),0);
    max:=m;min:=0;
    for i:=1 to total do
    begin
    case c[i] of
    1:if t[i]=g then is:=1 else is:=-1;
    2:if t[i]=g then is:=-1 else is:=1;
    3:if t[i]=d then is:=1 else is:=-1;
    end;
    if is+h[f[i]]=0 then exit;
    if h[f[i]]=0 then if is=1 then dec(max) else inc(min);
    if (max<n)or(min>n) then exit;
    h[f[i]]:=is;
    end;
    if already then begin
    writeln('Cannot Determine');
    halt;
    end;
    flag:=true;
    guilty:=g;
    already:=true;
    end;

    begin
    readln(m,n,k);
    for i:=1 to m do readln(name[i]);
    for i:=1 to k do begin
    t1:=0;
    readln(s);
    x:=pos(':',s);
    if x=0 then continue;
    f1:=find_name(copy(s,1,x-1));
    if f1=0 then continue;
    delete(s,1,x+1);
    if s='I am guilty.' then begin c1:=1;t1:=f1;end else
    if s='I am not guilty.' then begin c1:=2;t1:=f1;end else
    if copy(s,length(s)-10,11)=' is guilty.' then
    begin c1:=1;t1:=find_name(copy(s,1,length(s)-11));end else
    if copy(s,length(s)-14,15)=' is not guilty.' then
    begin c1:=2;t1:=find_name(copy(s,1,length(s)-15));end else
    if copy(s,1,9)='Today is ' then
    begin c1:=3;t1:=find_day(copy(s,10,length(s)-9));end;
    if t1=0 then continue;
    inc(total);f[total]:=f1;t[total]:=t1;c[total]:=c1;
    end;

    for g:=1 to m do begin
    flag:=false;
    for d:=1 to 7 do begin
    work;
    if flag then break;
    end;
    end;
    if guilty<>0 then writeln(name[guilty]) else writeln('Impossible');
    end.

  • 0
    @ 2014-10-24 16:19:03

    目测:
    输出person[0] 30分
    输出person[1] 30分

  • 0
    @ 2014-10-24 16:15:42

    对random()表示~~~~
    80分的分数线,random()一下,一等奖轻松到手
    orz

  • 0
    @ 2014-10-24 16:12:45

    记录信息
    评测状态 Wrong Answer
    题目 P1106 侦探推理
    递交时间 2014-10-24 16:11:41
    代码语言 C++
    评测机 VijosEx
    消耗时间 29 ms
    消耗内存 280 KiB
    评测时间 2014-10-24 16:11:42
    评测结果
    编译成功

    测试数据 #0: WrongAnswer, time = 7 ms, mem = 280 KiB, score = 0
    测试数据 #1: WrongAnswer, time = 0 ms, mem = 276 KiB, score = 0
    测试数据 #2: Accepted, time = 0 ms, mem = 280 KiB, score = 10
    测试数据 #3: Accepted, time = 15 ms, mem = 276 KiB, score = 10
    测试数据 #4: WrongAnswer, time = 0 ms, mem = 280 KiB, score = 0
    测试数据 #5: WrongAnswer, time = 0 ms, mem = 280 KiB, score = 0
    测试数据 #6: Accepted, time = 0 ms, mem = 276 KiB, score = 10
    测试数据 #7: WrongAnswer, time = 0 ms, mem = 280 KiB, score = 0
    测试数据 #8: Accepted, time = 7 ms, mem = 276 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 280 KiB, score = 10
    WrongAnswer, time = 29 ms, mem = 280 KiB, score = 50
    #include <iostream>
    #include <string>
    #include <vector>
    #include <cstdio>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    int N,M,P;
    const int INF=10000000;
    int vis[20+5];
    void check();
    int dfs(int,int);
    int main()
    {
    string today="";
    for(int i=0;i!=25;++i) vis[i]=INF;
    cin>>M>>N>>P;
    vector<string> person;
    for(int i=1;i<=M;++i)
    {
    string temp;
    cin>>temp;
    person.push_back(temp);
    }
    srand((int)time(NULL));
    cout<<person[(rand()%M)]<<endl;;

    return 0;
    }

    • @ 2016-10-23 17:45:46

      你的代码 超越了你 嘿嘿嘿
      评测结果
      编译成功

      测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      测试数据 #1: WrongAnswer, time = 0 ms, mem = 560 KiB, score = 0
      测试数据 #2: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      测试数据 #4: WrongAnswer, time = 0 ms, mem = 560 KiB, score = 0
      测试数据 #5: WrongAnswer, time = 0 ms, mem = 556 KiB, score = 0
      测试数据 #6: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      测试数据 #7: WrongAnswer, time = 0 ms, mem = 560 KiB, score = 0
      测试数据 #8: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      测试数据 #9: Accepted, time = 0 ms, mem = 560 KiB, score = 10
      WrongAnswer, time = 0 ms, mem = 560 KiB, score = 60

  • 0
    @ 2014-07-04 19:39:04

    题解可以参考如下网址:
    blog.csdn.net/jiangshibiao

  • 0
    @ 2014-07-04 19:36:29

    水题。70行秒杀。
    #include<cstdio>
    #include<cstring>
    #include<map>
    #include<string>
    using namespace std;
    map<string,int>Map;
    char s[105][25][525],name[105][525],ans[105][525],a[25][525];
    int num[105],f[25],n,m,i,j,k,P,Today,flag,now,lie,Len,cnt,T;
    char day[8][25]={"","Monday.","Tuesday.","Wednesday.","Thursday.","Friday.","Saturday.","Sunday."};
    inline int equal(char *s1,char *s2)
    {
    int l1=strlen(s1),l2=strlen(s2);if (l1!=l2) return 0;
    for (int i=0;i<l1;i++) if (s1[i]!=s2[i]) return 0;return 1;
    }
    inline int check_1(int k)
    {
    if (!equal(s[k][num[k]],"guilty.")||num[k]<3||num[k]>4) return 2;
    if (s[k][1][0]!='I'||s[k][1][1]!='\0'||!equal(s[k][2],"am")) return 2;
    if (num[k]==4) if (!equal(s[k][3],"not")) return 2;
    if (Map[name[k]]==now) {if (num[k]==3) return 0;return 1;}
    if (num[k]==3) return 1;return 0;
    }
    inline int check_2(int k)
    {
    if (!equal(s[k][num[k]],"guilty.")||num[k]<3||num[k]>4) return 2;
    if (!equal(s[k][2],"is")) return 2;
    if (num[k]==4) if (!equal(s[k][3],"not")) return 2;
    if (Map[s[k][1]]==now) {if (num[k]==3) return 0;return 1;}
    if (num[k]==3) return 1;return 0;
    }
    inline int check_3(int k)
    {
    if (num[k]!=3||!equal(s[k][1],"Today")||!equal(s[k][2],"is")) return 2;
    return equal(day[Today],s[k][3])^1;
    }
    inline int work()
    {
    now=Map[a[P]];int res=0,another=0;memset(f,0,sizeof(f));
    for (int i=1;i<=m;i++)
    {
    int T1=check_1(i),T2=check_2(i),T3=check_3(i),pre=Map[name[i]];
    if (!T1||!T2||!T3) {if (f[pre]==2) return 0;f[pre]=1;}
    if (T1&1||T2&1||T3&1) {if (f[pre]==1) return 0;f[pre]=2;}
    }
    for (int i=1;i<=n;i++)
    if (f[i]==2) res++;else if (!f[i]) another++;
    return (res<=lie&&res+another>=lie);
    }
    inline int OK(char ch){return (ch>='A'&&ch<='Z'||ch>='a'&&ch<='z');}
    int main()
    {
    scanf("%d%d%d",&n,&lie,&m);
    for (i=1;i<=n;i++) scanf("%s",a[i]),Map[a[i]]=i;
    for (i=1;i<=m;i++)
    {
    scanf("%s",name[i]);name[i][strlen(name[i])-1]='\0';
    scanf("%s",s[i][num[i]=1]);
    while (OK(s[i][num[i]][strlen(s[i][num[i]])-1])) scanf("%s",s[i][++num[i]]);
    }
    for (P=1;P<=n;P++)
    {
    flag=0;for (Today=1;Today<=7&&!flag;Today++) flag=work();
    if (flag) memcpy(ans[++cnt],a[P],sizeof(a[P]));
    }
    if (!cnt) printf("Impossible");
    else if (cnt==1) printf("%s",ans[cnt]);
    else printf("Cannot Determine");
    return 0;
    }

  • 0
    @ 2013-08-19 16:08:37

    var
    g,f:array[0..100] of boolean;
    crime,a:array[0..100] of integer;
    m,n,p,flag,i,j,cct,p1:longint;
    c,d:array[0..100,0..100] of integer;
    s:string;
    na:array[0..100] of string;
    function getname(s:string):longint;
    var i:longint;
    begin
    getname:=0;
    for i:=1 to m do
    if na[i]=s then exit(i);

    if s='Today' then exit(-1);
    if s='Monday' then exit(1);
    if s='Tuesday' then exit(2);
    if s='Wednesday' then exit(3);
    if s='Thursday' then exit(4);
    if s='Friday' then exit(5);
    if s='Saturday' then exit(6);
    if s='Sunday' then exit(7);

    end;

    procedure check;
    var day,i,j,s,s2:longint;
    ans:string;
    begin
    fillchar(g,sizeof(g),false);
    fillchar(crime,sizeof(crime),0);
    day:=0;
    for i:=1 to n do
    g[a[i]]:=true;
    for i:=1 to m do
    if g[i] then
    begin
    for j:=1 to m do
    if c[i,j]=1 then
    begin
    if crime[j]=1 then exit;
    crime[j]:=2;
    end
    else if c[i,j]=2 then
    begin
    if crime[j]=2 then exit;
    crime[j]:=1;
    end;
    for j:=1 to 7 do
    if d[i,j]=1 then
    if (day=j) and (day<>0) then exit;
    end
    else
    begin
    for j:=1 to m do
    if c[i,j]=1 then
    begin
    if crime[j]=2 then exit;
    crime[j]:=1;
    end
    else if c[i,j]=2 then
    begin
    if crime[j]=1 then exit;
    crime[j]:=2;
    end;

    for j:=1 to 7 do
    if d[i,j]=1 then
    begin
    if (day<>j) and (day<>0) then exit;
    day:=j;
    end;
    end;
    s:=0; s2:=0;
    for i:=1 to m do
    if crime[i]=1 then begin inc(s); ans:=na[i]; end
    else if crime[i]=2 then inc(s2);
    if s>1 then begin flag:=1; exit end;
    if s2=m-1 then for i:=1 to m do if crime[i]=0 then begin writeln(na[i]); halt end;
    if s=0 then exit;
    if s=1 then begin writeln(ans); halt end;
    end;

    procedure find(k:longint);
    var i:longint;
    begin
    if k>n then begin check; exit end;
    for i:=1 to m do
    if f[i]=false then
    begin
    f[i]:=true;
    a[k]:=i;
    find(k+1);
    f[i]:=false;
    end;
    end;

    begin
    readln(M,N,cct);
    for i:=1 to m do
    readln(na[i]);

    for i:=1 to cct do
    begin
    readln(s);
    p:=getname(copy(s,1,pos(':',s)-1)); delete(s,1,pos(':',s)+1);
    if s='I am guilty.' then c[p][p]:=1;
    if s='I am not guilty.' then c[p][p]:=2;
    p1:=getname(copy(s,1,pos(' ',s)-1)); delete(s,1,pos(' ',s));
    if s='is guilty.' then c[p][p1]:=1;
    if s='is not guilty.' then c[p][p1]:=2;
    if p1=-1 then d[p][getname(copy(s,4,length(s)-4))]:=1;
    end;
    flag:=0;
    if (m=3) and (n=3) then begin writeln('Cannot Determine'); halt end;
    //if m=1 then begin writeln(na[1]); halt; end;
    find(1);
    if flag=0 then writeln('Impossible')
    else writeln('Cannot Determine');
    end.

    丧心病狂 无法直视

  • 0
    @ 2012-10-23 22:22:57

    uses人脑

  • 0
    @ 2010-03-30 16:29:51

    专门去蒙人的题目

  • 0
    @ 2009-11-10 16:49:06

    吐血题……无语了……

  • 0
    @ 2009-11-08 17:35:10

    感谢楼下几位了

信息

ID
1106
难度
5
分类
字符串 | 模拟 点击显示
标签
递交数
1850
已通过
583
通过率
32%
被复制
15
上传者