跳到正文

个人记录

T677920 小田的二分2

cyc27约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年5月6日
收录
2026年5月6日
更新
2026年11月20日
篇幅
约 1 分钟
获赞
1

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int n;
int vis[100000005];
int x,q,tmp;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        vis[x]=i;
    }
    cin>>q;
    while(q--){
        cin>>tmp;
        if(!vis[tmp]){
            cout<<-1<<" ";
        }else{
            cout<<vis[tmp]<<" ";
        }
    }
    return 0;
}
原文