zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    final-第十章
    路由器基本配置-命令行配置模式
    路由器基本配置-对话配置模式
    配置静态路由
    默认路由
    像素值的读写
    矩阵的基本元素表达
    创建Mat对象
    Mat类
    数学基础-3D空间的位置表示
  • 原文地址:https://www.cnblogs.com/sola1994/p/4630491.html
Copyright © 2011-2022 走看看