line 1 is too short......
查看原帖
line 1 is too short......
205782
R浩轩泽Anmicius楼主2020/6/23 18:15

又是被橙题卡的一天......

使用find函数搞小根堆果然还是出错了

劳烦各位奆佬纠正

#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
int n;
string s1,s;
priority_queue<string,vector<string>,greater<string> >q;
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s1;
		q.push(s1);//按照字典序排列字符串 
	}
	cin>>s;
	while(n--)
	if(!q.top().find(s))//差找该字符串是否存在s前缀 
	{
		cout<<q.top()<<'\n';
		q.pop(); //弹出 
	}
	return 0;
}

非常感谢!!!

2020/6/23 18:15
加载中...