zoukankan      html  css  js  c++  java
  • Codeforces441A_Valera and Antique Items(水题)

    Valera and Antique Items
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Valera is a collector. Once he wanted to expand his collection with exactly one antique item.

    Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of the i-th seller issij. Valera gets on well with each of the n sellers. He is perfectly sure that if he outbids the current price of one of the items in the auction (in other words, offers the seller the money that is strictly greater than the current price of the item at the auction), the seller of the object will immediately sign a contract with him.

    Unfortunately, Valera has only v units of money. Help him to determine which of the n sellers he can make a deal with.

    Input

    The first line contains two space-separated integers n, v (1 ≤ n ≤ 50; 104 ≤ v ≤ 106) — the number of sellers and the units of money the Valera has.

    Then n lines follow. The i-th line first contains integer ki (1 ≤ ki ≤ 50) the number of items of the i-th seller. Then go ki space-separated integers si1, si2, ..., siki (104 ≤ sij ≤ 106) — the current prices of the items of the i-th seller.

    Output

    In the first line, print integer p — the number of sellers with who Valera can make a deal.

    In the second line print p space-separated integers q1, q2, ..., qp (1 ≤ qi ≤ n) — the numbers of the sellers with who Valera can make a deal. Print the numbers of the sellers in the increasing order.

    Sample test(s)
    input
    3 50000
    1 40000
    2 20000 60000
    3 10000 70000 190000
    
    output
    3
    1 2 3
    
    input
    3 50000
    1 50000
    3 100000 120000 110000
    3 120000 110000 120000
    
    output
    0
    
    
    Note

    In the first sample Valera can bargain with each of the sellers. He can outbid the following items: a 40000 item from the first seller, a20000 item from the second seller, and a 10000 item from the third seller.

    In the second sample Valera can not make a deal with any of the sellers, as the prices of all items in the auction too big for him.

    解题报告

    切水题。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    int n,v,hashh[10000],k,s;
    int main()
    {
        int i,j;
        while(cin>>n>>v)
        {
            memset(hashh,0,sizeof(hashh));
            for(i=1; i<=n; i++)
            {
                cin>>k;
                for(j=0; j<k; j++)
                {
                    cin>>s;
                    if(s<v)
                        hashh[i]=1;
                }
            }
            int cnt=0;
            for(i=1; i<=n; i++)
            {
                if(hashh[i])
                {
                    cnt++;
                }
            }
            printf("%d
    ",cnt);
            for(i=1;i<n;i++)
            {
                if(hashh[i])
                {
                    printf("%d ",i);
                }
            }
            if(hashh[n])
                printf("%d",n);
            printf("
    ");
        }
        return 0;
    }
    


  • 相关阅读:
    gets_s()函数的参数太少,strcpy_s():形参和实参 2 的类型不同,等c函数在Visual Studio上出现的问题, get()函数和scanf()读取字符串的区别,栈的随机性
    线性表的顺序存储实现
    汉诺塔问题, 用递归方法求集合中的中位数
    共用体union
    洛谷3384:【模板】树链剖分——题解
    BZOJ4196:[NOI2015]软件包管理器——题解
    BZOJ3140:[HNOI2013]消毒——题解
    BZOJ1059:[ZJOI2007]矩阵游戏——题解
    洛谷4277:萃香的请柬——题解
    BZOJ1854:[SCOI2010]连续攻击游戏——题解
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10558047.html
Copyright © 2011-2022 走看看