POJ 2535 Very Simple Problem
2011-04-26 16:52
363 查看
http://poj.org/problem?id=2535
Very Simple Problem
Description
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 file 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
Sample Output
Very Simple Problem
Time Limit: 2000MS | Memory Limit: 65536K | |
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 file 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
/* Author : yan * Question : POJ 2535 VerySimple Problem * Date && Time : Tuesday, April 26 2011 04:45 PM * Compiler : gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 */ #include<stdio.h> #define MAXSIZE 105 #define MIN 0xFFFF #define MAX -1 #define bool _Bool #define TRUE 1 #define FALSE 0 int input[MAXSIZE],count[MAXSIZE]; bool hard[MAXSIZE]; int main() { //freopen("input","r",stdin); int n,p; int i,j; bool flag=FALSE; int max,min; scanf("%d %d",&n,&p); for(i=0;i<n;++i) { for(j=0;j<p;++j) scanf("%d",&input[j]); max=MAX,min=MIN; for(j=0;j<p;++j) { if(max<input[j]) max=input[j]; if(min>input[j]) min=input[j]; } //printf("MAX=%d MIN=%d/n",max,min); for(j=0;j<p;++j) { //printf("input[%d]=%d min=%d/n",j,input[j],min); if(input[j]==max) hard[j]=TRUE; if(input[j]==min) count[j]++; } } for(i=0;i<p;++i) { if( hard[i]==FALSE && count[i]>n/2 ) printf("%d ",i+1),flag=TRUE; //printf("%d ",count[i]); } if(!flag) printf("0"); printf("/n"); return 0; }[/code]
相关文章推荐
- POJ 2535 Very Simple Problem
- POJ 2535 Very Simple Problem G++
- poj 2535 Very Simple Problem
- poj 2535 Very Simple Problem
- POJ 2535 Very Simple Problem(水~)
- poj 2535 Very Simple Problem
- POJ 2535 Very Simple Problem(我的水题之路——看错题)
- POJ 3483 A Very Simple Problem
- poj 3468 A Simple Problem with Integers(线段树)
- POJ 3468 A Simple Problem with Integers(树状数组区间更新) 续
- POJ 3468 A Simple Problem with Integers(线段树区间更新模板题)
- POJ - 3468 A Simple Problem with Integers
- POJ 3468 A Simple Problem with Integers(线段树区间更新+求和)
- POJ 3468 A Simple Problem with Integers (区间增减)
- POJ 3468 A Simple Problem with Integers(线段树 插线问线)
- poj 3468 A Simple Problem with Integers(线段树区间更新)
- POJ 3468 A Simple Problem with Integers 线段树区间更新 (值在基础上相加或相减)
- poj 3468 A Simple Problem with Integers
- POJ 3468 A Simple Problem with Integers
- poj-3468-A Simple Problem with Integers(线段树)