poj 2535 Very Simple Problem
2011-11-22 12:28
302 查看
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
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 3250 | Accepted: 1211 |
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
#include<iostream> using namespace std; int main() { int a[101][101]; int b[101][2]; int n,p; int i,j; int max,min; int flag; int num; scanf("%d %d",&n,&p); for(i=1;i<=n;i++) { b[i][0]=1; } for(i=1;i<=n;i++) { max=min=1; for(j=1;j<=p;j++) { scanf("%d",&a[i][j]); if(a[i][min]>a[i][j]) min=j; else if(a[i][max]<a[i][j]) max=j; } for(j=1;j<=p;j++) if(a[i][j]==a[i][max]) b[j][0]=0; b[i][1]=a[i][min]; } flag=1; for(i=1;i<=n;i++) { if(b[i][0]) { num=0; for(j=1;j<=n;j++) { if(a[j][i]==b[j][1]) num++; } if(num>n/2) { flag=0; printf("%d ",i); } } } if(flag) printf("0\n"); return 0; }
相关文章推荐
- POJ 2535 Very Simple Problem
- 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 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(线段树成段更新lazy)
- POJ 3468 A Simple Problem with Integers
- POJ-3468-A Simple Problem with Integers(线段树区间维护 重写Lazy)
- 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