超时了帮帮本蒻只因
查看原帖
超时了帮帮本蒻只因
981833
Joseph_J楼主2023/7/6 13:25
#include<bits/stdc++.h>

using namespace std;
int a[1000001];
int q[100001];
bool t=false;
int main(){
	
	int n,m;
	cin>>n>>m;
	
	for(int w=1;w<=n;w++){
		
		cin>>a[w];
	}
	
	for(int i=1;i<=m;i++){
		
		cin>>q[i];
	}
	
	for(int e=1;e<=m;e++){
		
		t=false;
		for(int r=1;r<=n;r++){
			
			if(q[e]==a[r]){
				
				t=true;
				cout<<r<<' ';
				break; 
			}else{
				t=false;
			}
			
		}
		if(t==false){	
			cout<<"-1"<<' ';
			}	
	}
	
	return 0;
} 
2023/7/6 13:25
加载中...