玄学事件(玄关)
查看原帖
玄学事件(玄关)
1073741
UKE_bound楼主2024/7/8 18:29
#include<bits/stdc++.h> 
using namespace std;
const string days[7]{
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday"
};
struct mess{//证词 
	string w/*说话人*/,x/*内容*/;
	int c/*消息类型*/;
	//c=1:w:x是罪犯 
	//c=2:w:x不是罪犯 
	//c=3:w:今天是x 
};
bool analy(string a,mess& res){
	//把一个条证词转化为mess对象 
	int f=a.find(':');
	res.w=a.substr(0,f);
	a=a.substr(f+2,a.size());
	if(~a.find("I am guilty")){
		res.c=1;
		res.x=res.w;
		return 1;
	}
	if(~a.find("I am not guilty")){
		res.c=2;
		res.x=res.w;
		return 1;
	}
	int k;
	if(~(k=a.find("Today is "))){
		res.c=3;
		res.x=a.substr(9,a.size());
		res.x.erase(res.x.end()-1);
		return 1;
	}
	if(~(k=a.find(" is guilty"))){
		res.c=1;
		res.x=a.substr(0,k);
		return 1;
	}
	if(~a.find(" is not guilty")){
		res.c=2;
		res.x=a.substr(0,k);
		return 1;
	}
	return 0; 
}
int m,n,p;
vector<mess> ms;
vector<string> name;
int main(){
	cin>>m>>n>>p;
	name=vector<string>(m);
	for(int i=0;i<m;i++){
		cin>>name[i];
	}
	for(int i=0;i<p;i++){
		string t;
		cin>>t;
		mess a;
		if(analy(t,a)){
			ms.push_back(a);
		}
	}
	for(int i=0;i<ms.size();i++){
		cout<<ms[i].w<<" "<<ms[i].c<<" "<<ms[i].x<<endl;
	}
	return 0;
}

输入样例后得到:

但是

#include<bits/stdc++.h> 
using namespace std;
const string days[7]{
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday"
};
struct mess{//证词 
	string w/*说话人*/,x/*内容*/;
	int c/*消息类型*/;
	//c=1:w:x是罪犯 
	//c=2:w:x不是罪犯 
	//c=3:w:今天是x 
};
bool analy(string a,mess& res){
	//把一个条证词转化为mess对象 
	int f=a.find(':');
	res.w=a.substr(0,f);
	a=a.substr(f+2,a.size());
	if(~a.find("I am guilty")){
		res.c=1;
		res.x=res.w;
		return 1;
	}
	if(~a.find("I am not guilty")){
		res.c=2;
		res.x=res.w;
		return 1;
	}
	int k;
	if(~(k=a.find("Today is "))){
		res.c=3;
		res.x=a.substr(9,a.size());
		res.x.erase(res.x.end()-1);
		return 1;
	}
	if(~(k=a.find(" is guilty"))){
		res.c=1;
		res.x=a.substr(0,k);
		return 1;
	}
	if(~a.find(" is not guilty")){
		res.c=2;
		res.x=a.substr(0,k);
		return 1;
	}
	return 0; 
}
int m,n,p;
vector<mess> ms;
vector<string> name;
int main(){
	string a;
	mess s;
	getline(cin,a);
	if(analy(a,s)){
		cout<<s.c<<endl<<s.w<<endl<<s.x;
	}
	return 0;
}

输入: MIKE: I am guilty.

输出:

这是什么玄学事件啊!

2024/7/8 18:29
加载中...