40分求助!
查看原帖
40分求助!
704634
poor_OIer楼主2023/7/25 20:58

样例过了,但WA #4 #6 #7 #8 #9 #10.

#include<bits/stdc++.h>
using namespace std;
string text[10005];
long long tot,KPM;
double t;
long long ans;
stack<char> q;
stack<char> st;
int main()
{
	ios::sync_with_stdio(false);
	while(1)
	{
		string s;
		getline(cin,s);
		if(s=="EOF")
			break;
		text[++tot]=s;
	}
	//for(int i=1;i<=tot;i++)
	//	cout<<text[i]<<endl;
	tot=0;
	while(1)
	{
		int len=0;
		tot++;
		string s;
		getline(cin,s);
		if(s=="EOF")
			break;
		while(!q.empty())
			q.pop();
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='<')
			{
				if(!q.empty())
					q.pop();
			}
			else
				q.push(s[i]);
		}
		/*while(!q.empty())
			cout<<q.top(),q.pop();
		cout<<endl;*/
		while(!q.empty())
		{
			st.push(q.top());
			q.pop();
		}
		while(!st.empty())
		{
			char ch=st.top();
			if(ch==text[tot][len++])
				ans++;
			st.pop();
		}
	}
	cin>>t;
	KPM=ans*60.0/t+0.5;
	cout<<KPM;
	return 0;
}
2023/7/25 20:58
加载中...