poj2535
简单题
View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define maxn 105
int n, p;
int f[maxn];
bool hard[maxn];
int point[maxn];
int main()
{
//freopen("t.txt", "r", stdin);
scanf("%d%d", &n, &p);
memset(f, 0, sizeof(f));
memset(hard, 0, sizeof(hard));
for (int i = 0; i < n; i++)
{
int s = 0x3f3f3f3f, h = 0;
for (int j = 0; j < p; j++)
{
scanf("%d", &point[j]);
s = min(s, point[j]);
h = max(h, point[j]);
}
for (int j = 0; j < p; j++)
{
if (s == point[j])
f[j]++;
if (h == point[j])
hard[j] = true;
}
}
int i = 0;
while (i < p && (hard[i] || f[i] <= n / 2))
i++;
if (i == p)
{
printf("0\n");
return 0;
}
printf("%d", i + 1);
for (int j = i + 1; j < p; j++)
if (!hard[j] && f[j] > n / 2)
printf(" %d", j+ 1);
putchar('\n');
return 0;
}