Untitled
unknown
plain_text
2 years ago
1.1 kB
3
Indexable
#include <bits/stdc++.h> using namespace std; #define ll long long #define ldb long double #define x first #define y second #define p pair<ll, ll> #define vt vector<ll> #define pb push_back #define all(x) x.begin(), x.end() #define tp pair<ll, pair<ll, ll>> #define fi first #define se second.first #define th second.second const long long MOD = 1000000007; const long double PI = 3.141592653589793238462643383279502884; const long long INF = 1e18; void solve(){ ll n, q; cin >> n >> q; vt a(n); for(auto &it:a) cin >> it; map<ll, ll> m; for(int i = 0; i < n; i++) m[a[i]] = INF; for(int i = 0; i < n; i++) { m[a[i]] = min(m[a[i]], ll(i + 1)); } while(q--) { ll k; cin >> k; cout << m[k] << '\n'; } } int main (){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q = 1; cin >> q; while(q--){ solve(); } return 0; }
Editor is loading...