要帮帮捏~
查看原帖
要帮帮捏~
475532
Alexandr楼主2024/7/19 11:45

这道题好坏,一直找不出问题滴,好急呢

只拿了 90 分,我要崩溃了呜呜呜,快哭了

#include<bits/stdc++.h>
#define _rep(i,a,b) for(int i=(a);i<=(b);i++)
#define _antirep(i,a,b) for(int i=(a);i>=(b);i--) 
using namespace std;
typedef long long LL;
typedef double db;
const int N=1e5+5,mod=1e9+7;
int n,cnt;
string teacher[6],student[6],pp;
bool f[6],nows[6],nowt=false; 
signed main()
{        
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n;
	_rep(i,1,3) cin>>teacher[i];
	_rep(i,1,5) cin>>student[i];
//	getline(cin,pp);
	_rep(pos,1,n)
	{ 
		//cout<<pos<<endl;
		string a,b;
		cin>>a;
		int ok=0;
		_rep(i,1,3) if(a==teacher[i]) ok=1;
		_rep(i,1,5) if(a==student[i]) ok=2; 
		getline(cin,b); 
		if(ok==0) 
		{
			continue;
		}
		if(ok==1)
		{
			if(b==" came!")
			{ 
				_rep(i,1,3)
				{
					if(a==teacher[i])
					{
						nowt=true;
						break;
					}
				}
			}
			if(b==" left!")
			{ 
				_rep(i,1,3)
				{
					if(a==teacher[i])
					{
						nowt=false;
						break;
					}
				}
			}
		}
		if(ok==2)
		{
			if(b==" started playing games!")
			{	  
				_rep(i,1,5)
				{
					if(a==student[i])
					{
						nows[i]=1;
						break;
					}
				}
			}
			if(b==" stopped playing games!")
			{ 
				_rep(i,1,5)
				{
					if(a==student[i])
					{
						nows[i]=0;
						break;
					}
				}
			} 
		}
		if(nowt)_rep(i,1,5)f[i]|=nows[i];
	} 
	int res=0;
	_rep(i,1,5) if(f[i]) cout<<student[i]<<" ",cnt++;
	if(cnt==0) cout<<"How Good Oiers Are!";
	else if(cnt==5) cout<<"\nHow Bad Oiers Are!";
	return 0;
}
2024/7/19 11:45
加载中...