/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 37ms 568.0 KiB
#3 Accepted 46ms 888.0 KiB
#4 Accepted 44ms 836.0 KiB
#5 Accepted 125ms 7.773 MiB
#6 Accepted 136ms 7.781 MiB

Code

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#ifdef velox
#include "debug.h"
#else
#define debug(x...)
#endif

#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define set_bits(x) __builtin_popcountll(x)
#define fst_zero(x) 63-__builtin_ctzll(x)
#define lst_zero(x) __builtin_ctzll(x)
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) ((x/gcd(x,y))*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define ll long long
#define pb push_back
#define endl '\n'
#define fx(x) fixed<<setprecision(x)
template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll MOD = 1e9+7;

void error_txt(){
	#ifdef velox
	freopen("error.txt","w",stderr);
	#endif
}



void solve(){
	ll len; cin >> len;
	vector<ll> v(len);
	map<ll,ll> mp;

	for(int x=0; x<len; x++){
		cin >> v[x];
		mp[v[x]]=x+1;
	}


	ll q; cin >> q;
	while(q--){
		ll val; cin >> val;

		if(mp.find(val)==mp.end()){
			debug(mp);
			ll get=0;
			for(auto tt: mp){
				get=tt.second;
				break;
			}
			cout << get << endl;

			mp.erase(mp.begin());
			mp[val]=get;
			
		}
		else{
			cout << mp[val] << endl;
		}
	}
	
}

int main(){
	// error_txt();
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll t=1;
	// cin >> t;
	while(t--) solve();
	return 0;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 15:57:20
Judged At
2024-10-03 13:29:16
Judged By
Score
100
Total Time
136ms
Peak Memory
7.781 MiB