# 11255: 【原1255】你的魔戒？不，是你的魔戒。

### 题目描述

author: Kalethars 张晔 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/1255 ﻿

## Description

I have the ring. 我有魔戒。

I have not the ring. 我没有魔戒。

XXX has the ring. XXX有魔戒。(XXX表示某个霍比特人的名字)

XXX has not the ring. XXX没有魔戒。

Today is XXX. 今天天气真好，是XXX吧！(XXX表示Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday其中之一，只有首字母大写)

I have the ring. -> (speakerid, speakerid, 1)

I have not the ring. -> (speakerid, speakerid, 2)

XXX has the ring. -> (speakerid, XXX's id, 1)

XXX has not the ring. -> (speakerid, XXX's id, 2)

Today is XXX. -> (speakerid, xxx, 3)，其中(XXX=Monday->xxx=1, XXX=Tuesday->xxx=2, ..., XXX=Sunday->xxx=7)

## Input Format

M是半兽人抓到的霍比特人数，N是其中始终说谎的人数，P是得到的回答的总数。

## Sample Input

``````3 1 5
FRODO
SAM
GOLLUM
FRODO: I have the ring.
FRODO: Today is Sunday.
GOLLUM: FRODO has the ring.
SAM: I have the ring.
SAM: How are you??
``````

## Sample Output

``````0 0 1
0 7 3
2 0 1
1 1 1
``````

## WashSwang's solution

``````#include <iostream>
#include <string>
using namespace std;
string s,name[30],who,towho,days[7]={"Monday.","Tuesday.","Wednesday.","Thursday.","Friday.","Saturday.","Sunday."};
int m,n,p,mh,f,t,c,succ,pos;
char ch;
int findname(string name1)
{
for (int j=0;j<m;++j)
if (name1==name[j])
return j;
return -1;
}
int main() {
cin>>m>>n>>p;
ch=getchar();
for (int i=0;i<m;++i){
getline(cin,name[i]);
}
for (int i=0;i<p;++i){
getline(cin,s);
mh=s.find(':');
who=s.substr(0,mh);
c=-1;
f=findname(who);
if (f==-1) continue;
pos=s.find('.');
if (pos!=s.length()-1) continue;
pos=s.find(" have the ring.");
if (pos!=-1) {
if (pos - mh == 3 && s[pos - 1] == 'I' && s[mh + 2] == 'I') {
t = f;
c = 1;
}
}
else{
pos=s.find(" have not the ring.");
if (pos!=-1) {
if (pos - mh == 3 && s[pos - 1] == 'I' && s[mh + 2] == 'I') {
t = f;
c = 2;
}
}
else{
pos=s.find(" has the ring.");
if (pos!=-1){
t=findname(s.substr(mh+2,pos-2-mh));
if (t!=-1) c=1;
}
else{
pos=s.find(" has not the ring.");
if (pos!=-1){
t=findname(s.substr(mh+2,pos-2-mh));
if (t!=-1) c=2;
}
else{
pos=s.find(" Today is ");
if (pos!=-1){
t=-1;
for (int j=0;j<7;++j)
if (s.find(days[j])==pos+10)
{
t=j+1;
break;
}
if (t!=-1) c=3;
}
}
}
}
}
if (c!=-1)
{
succ++;
cout<<f<<" "<<t<<" "<<c<<endl;
}
}
if (!succ) cout<<"Orz"<<endl;
return 0;
}
``````