• hdu 5233 Gunner II (stl vector map)


    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<map>
    using namespace std;
    vector<int> a[100000+100];
    map <int,int> temp;
    int h[100000+100];
    int shoot[100000+100];
    int main()
    {
        int n,m;
        int i,j,k;
        int now;
        while(scanf("%d%d",&n,&m)!=EOF)
        {
            int t=0;
    
            for(int i=0;i<=n;i++) a[i].clear();
            temp.clear();
    
            for(i=1;i<=n;i++)
            {
                scanf("%d",&h[i]);//vec.push_back(a);
            }
    
            for(i=1;i<=m;i++)
            {
                scanf("%d",&shoot[i]);
            }
    
            for(i=n;i>=1;i--)
            {
                now=h[i];
                if(a[temp[now]].empty())
                {
                   temp[now]=++t;
                  // printf("%d...
    ",now);
                }
                //printf("*.......*
    ");
                a[temp[now]].push_back(i);
            }
            //printf("%d!!!
    ",a[2][a[2].size()-1]);
    
            for(i=1;i<=m;i++)
            {
                 now=temp[shoot[i]];
                 if(!a[now].empty())
                 {
                     int neww;
                     neww=a[now][a[now].size()-1];
                     a[now].pop_back();
                     printf("%d
    ",neww);
                 }
                 else
                 {
                     printf("-1
    ");
                 }
            }
        }
        return 0;
    }
    
  • 相关阅读:
    html 知识
    mysql use mysql hang
    微信机器人 简化版
    Tk::Table
    好友消息和群消息区别
    完整的微信登陆 接收消息流程
    Python OOP知识积累
    Python OOP知识积累
    JSTL EL 详解
    JSP中的EL表达式详细介绍
  • 原文地址:https://www.cnblogs.com/sola1994/p/4630491.html
Copyright © 2020-2023  润新知