Very Simple Problem(FZU 1350)

本文介绍了一种用于编程竞赛中筛选简单题目的算法。通过评估评委给出的复杂度评分,算法能够找出被多数评委认为最简单的题目,并确保这些题目在任何评委的评分中都不是最困难的。文章提供了一个具体的实现示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

During a preparation of programming contest, its jury is usually faced with many difficult tasks. One of them is to select a problem simple enough to most, if not all, contestants to solve.

 

The difficulty here lies in diverse meanings of the term "simple" amongst the jury members. So, the jury uses the following procedure to reach a consensus: each member weights each proposed problem with a positive integer "complexity rating" (not necessarily different for different problems). The jury member calls "simplest" those problems that he gave the minimum complexity rating, and "hardest" those problems that he gave the maximum complexity rating.

 

The ratings received from all jury members are then compared, and a problem is declared as "very simple", if it was called as "simplest" by more than a half of the jury, and was called as "hardest" by nobody.

Input

The first line of input file contains integers N and P, the number of jury members and the number of problems. The following N lines contain P integers in range from 0 to 1000 each - the complexity ranks. 1 <= N, P <= 100

Output

Output must contain an ordered list of problems called as "very simple", separated by spaces. If there are no such problems, output must contain a single integer 0 (zero).

Sample Input

4 4
1 1 1 2
5 900 21 40
10 10 9 10
3 4 3 5

Sample Output

3

 

题目描述:n,m,表示n个人,m个题目。每一行就是每一个人对于每一个题目的评价。题目:某一个题目的评价,在别人所有的题目评价中,1、不是最高的评价,2、是最低的评价。求这样人的数目,要求超过一半。则该问题被认为最简单的题目。输出题目标号。要求:1、这样的人数超过半数人2、这样的题目不能再某一个人中被认为最难。  这样的题目可能有多个 也可能没有 没有就输出0 。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
struct node
{
    int id;
    int a[101];
    int max1;
    int min1;
};
struct node1
{
    int id;
    int num;
    int flag;
} st[1000];
using namespace std;
int main()
{
    struct node stu[1001];
    int n,m,i,j,k,t,tt;
        while(scanf("%d %d",&n,&m)!=EOF){
        for(i=1; i<=n; i++)
        {
            stu[i].id=i;
            stu[i].max1=-1;
            stu[i].min1=10001;
            for(j=1; j<=m; j++)
            {
                scanf("%d",&stu[i].a[j]);
                if(stu[i].max1<stu[i].a[j])
                {
                    stu[i].max1=stu[i].a[j];
                }
                if(stu[i].min1>stu[i].a[j])
                {
                    stu[i].min1=stu[i].a[j];
                }
            }
        }
        for(i=1; i<=m; i++)
        {
            st[i].flag=0;
            st[i].num=0;
            for(j=1; j<=n; j++)
            {
                int t=stu[j].a[i];
                if(t==stu[j].max1)
                {
                    st[i].flag=1;
                }
                else if(t==stu[j].min1)
                {
                    st[i].num++;
                }
            }
        }
        int flag=0;
        int v;
        int a[1000];
        int cont=0;
        for(i=1; i<=m; i++)
        {
            if(st[i].num>n/2&&st[i].flag==0)
            {
                a[cont++]=i;
            }
        }
        if(cont!=0)
        {
           for(i=0;i<cont;i++)
           {
               printf("%d",a[i]);
               if(i<cont-1)
                printf(" ");
           }
           printf("\n");
        }
        else
        {
            printf("0\n");
        }
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值