http://acm.hdu.edu.cn/showproblem.php?pid=5233
/* discretization with map and set, discretization is the renumbering of big data *//************************************************* Author:P owatr* Created time : 2015-8-12 18:27:42* File name:hdu5233 gunner II.cpp ************************************************/#include <cs tdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring># Include <cmath> #include <string> #include <vector> #include <queue> #include <deque># Include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime>using namespace std; #define Lson L, Mid, RT << 1#define Rson mid + 1, R, RT < ;< 1 | 1typedef long ll;const int MAXN = 1e5 + 10;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;set<int> S[MAXN]; Map<int, int> mp;int main () {int n, m; int x; while (~SCANF ("%d%d", &n, &m)) {for (int i = 1; I <= n; i++) s[i].clear (); Mp.clear (); int cnt = 0; for (int i = 1; I <= n; i++) {scanf ("%d", &x); if (!mp[x]) mp[x] = ++cnt; S[mp[x]].insert (i); } for (int i = 1; I <= m; i++) {scanf ("%d", &x); if (!s[mp[x]].size ()) puts ("-1"); else {printf ("%d\n", * (S[mp[x]].begin ())); S[mp[x]].erase (S[mp[x]].begin ()); }}} return 0;}
hdu5233--discretization of--gunner II