Sunday, 5 August 2012

UVa 11991 - Easy Problem from Rujia Liu? Solution

#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>

using namespace std;

#define INF (1<<29)
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define FILL(a,v) memset(a,v,sizeof(a))
#define PB push_back
#define FOR(i,n) for(int i = 0;i<n;i++)
#define PI acos(-1.0)
#define EPS 1e-9
#define MP(a,b) make_pair(a,b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define LL long long
#define MX 1000010
#define MOD 1000000007

vector<int>vctr[MX];
int arr[MX];
main()
{
    int n,m,k,v;
    while(cin>>n>>m)
    {
        for(int i=0;i<MX;i++)
            vctr[i].clear();

        for(int i=0;i<n;i++)
            //cin>>arr[i];
            {
                scanf("%d",&arr[i]);
                vctr[arr[i]].PB(i+1);
            }
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&k,&v);
            if(vctr[v].size()<k)
                printf("0\n");
            else
                printf("%d\n",vctr[v][k-1]);
        }


    }
return 0;
}

1 comment:

  1. ভাই c তে কিভাবে করব? সি তে ১০০০০১০ সাইজের অ্যারে নেওয়া যায় না

    ReplyDelete