文章

121

粉丝

68

获赞

94

访问

20.3k

头像
动态查找的问题 题解:利用set
P5127
发布于2025年2月5日 15:20
阅读数 78

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin>>n){
	    set<int>a;
	    while(n--){
	        int x;cin>>x;
	        a.insert(x);
	    }
	    int m;
	    cin>>m;
	    while(m--){
	        int y;cin>>y;
	        if(a.find(y)!=a.end())cout<<"find"<<endl;
	        else {
	            cout<<"no"<<endl;
	            a.insert(y);
	        }
	    }
	}
}

如果你是c语言,那么就使用自定义的set

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发