zoukankan      html  css  js  c++  java
  • Codeforces gym 100685 A. Ariel 暴力

    A. Ariel
    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/gym/100685/problem/A

    Description

    King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up a swimming competition in the kingdom Merfolk. Thousands of creatures come to take part in competition, that's why it is too difficult to take the first place.

    For the King's beloved daughter Ariel this competition is the first in her life. Ariel is very kind, so she wants to give a lot of gold medals. Ariel says, that it is unfair to make a single ranking list for creatures that are so different. It is really a good result to be the fastest small fish without tail in Merfolk!

    Ariel chooses k important traits (such as size, tailness, rapacity and so on). A creature can either possess a trait or not (there are no intermediate options).

    A score is given for each creature (it doesn't matter how it was calculated) and the list of possessed traits f1, ..., fy is also given.

    Ariel wants to know the place occupied by creature a in a competition among creatures, who have the same traits h1, ..., ht. So if creature a doesn't have a trait hi, then all creatures in the competition are without this trait. If creature a has a trait hi, then all creatures in the competition have this trait. Other traits doesn't matter. The winner of the competition is a creature with the maximum score.

    Input

    The first line contains n (1 ≤ n ≤ 104) and k (1 ≤ k ≤ 10). The next n lines contain information about creatures: score (1 ≤ score ≤ 109), y (0 ≤ y ≤ k) — the number of possessed traits, and y numbers fi (1 ≤ fi ≤ k) — ids of possessed traits. All fi in one line are different.

    The next line contains m (1 ≤ m ≤ 105) — the number of queries from Ariel. The next m lines describe queries: a (1 ≤ a ≤ n) — the id of a creature, then t — the number of traits, then t numbers hi. All hi in one line are different.

    Output

    For each query output the place of a creature a in ranking list amount the corresponded creatures. If several creatures have the same score all of them take the same place.

    Sample Input

    3 2
    100 1 1
    50 1 2
    30 2 1 2
    12
    1 2 1 2
    1 1 1
    1 1 2
    1 0
    2 0
    2 1 1
    2 1 2
    2 2 2 1
    3 0
    3 2 1 2
    3 1 2
    3 1 1

    Sample Output

    1
    1
    1
    1
    2
    1
    1
    1
    3
    1
    2
    2

    HINT

    题意

    有物种,最多十个特征,并且有分数

    然后每次查询,x num hi……hnum

    然后问你满足这种特征的生物,这个x的分数排第几

    题解

    直接傻逼暴力就好了,不要想多了,出题人是懒的,数据是水的

    代码

    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define test freopen("test.txt","r",stdin)  
    #define maxn 1501
    #define mod 1000000007
    #define eps 1e-9
    const int inf=0x3f3f3f3f;
    const ll infll = 0x3f3f3f3f3f3f3f3fLL;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //**************************************************************************************
    
    vector<int> G[maxn];
    
    struct node
    {
        int x,y;
    };
    node kiss[200001];
    
    int main()
    {
        int n=read(),k=read();
        for(int i=0;i<n;i++)
        {
            kiss[i+1].x=read();
            int tmp=0;
            int num=read();
            for(int j=0;j<num;j++)
            {
                int x=read();
                tmp=tmp|(1<<(x-1));
            }
            kiss[i+1].y=tmp;
            G[tmp].push_back(kiss[i+1].x);
        }
        for(int i=0;i<maxn;i++)
            sort(G[i].begin(),G[i].end());
        int m=read();
        for(int i=0;i<m;i++)
        {
            int id=read(),num=read();
            int tmp=0;
            for(int j=0;j<num;j++)
            {
                int x=read();
                tmp=tmp|(1<<(x-1));
            }
            int ans=0;
            for(int i=0;i<maxn;i++)
                if((i&tmp)==(kiss[id].y&tmp))   
                    ans+=G[i].size()-(upper_bound(G[i].begin(),G[i].end(),kiss[id].x)-G[i].begin());
            printf("%d
    ",ans+1);
        }
    }
  • 相关阅读:
    帧率、码流与分辩率之间关系
    谈谈RGB、YUY2、YUYV、YVYU、UYVY、AYUV
    YUV422 to YUV420sp color invert
    mysql——数据库备份——使用mysqldump命令备份所有数据库
    mysql——表的导出——用mysqldump命令导出 文本文件
    mysql——数据还原——使用mysql命令还原
    mysql——表的导出——用mysqldump命令导出 xml文件
    mysql——表的导出——用select……into outfile导出 xls文件和文本文件
    mysql——表的导出——用mysql命令导出 文本文件 和 xls文件
    和菜鸟一起学linux之wifi学习记录基础知识
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4702923.html
Copyright © 2011-2022 走看看