2014
11-05

# Another Contest

The contest is beginning again! To make the contest more interesting, Competition Commission has developed a new rule: There are N problems initially, and for each problem, if one get an "Accepted", he can get some points, equal to the number of contestants that did not solve the problem. The score of each contestant was equal to the sum of points assigned to the problems solved by that contestant.
iSea participated in the contest, but he is confused by the complicated scoring rules, and now he is staring at the results, unable to determine his place in the final standings. Help iSea by writing a program that calculates his score and his ranking.
Before the contest, the contestants were assigned unique IDs from 1 to S inclusive, and iSea’s ID was P. The final standings of the competition list the contestants in descending order of their scores. In case of a tie, among the tied contestants, those who have solved more tasks will be listed ahead of those who have solved fewer tasks. In case of a tie by this criterion as well, the contestants with equal results will be listed in ascending order of their IDs.

There are several test cases in the input.

The first line of each case contains three integers N, S, P (0 < N, S <= 1000, 1 <= P <= S), their meaning are the same as the description.
Then N lines follows, each line contains S integers, whether 0 or 1, indicating the result of S contestants solving the N problems, 0 means this contestant haven’t solved this problem, 1 means solved.

The input terminates by end of file marker.

There are several test cases in the input.

The first line of each case contains three integers N, S, P (0 < N, S <= 1000, 1 <= P <= S), their meaning are the same as the description.
Then N lines follows, each line contains S integers, whether 0 or 1, indicating the result of S contestants solving the N problems, 0 means this contestant haven’t solved this problem, 1 means solved.

The input terminates by end of file marker.

3 3 3
1 0 1
1 0 1
1 0 0

2 2

#include<stdio.h>
#include<string.h>
#include<algorithm>
const int maxn =1005;
struct data
{
int id;
int score;
}e[maxn];
bool vis[maxn];
bool cmp(const data &a,const data &b)
{
if(a.score!=b.score)
return a.score>b.score;
else
{
else return a.id<b.id;
}
}
int main()
{
int n,s,p;
while(scanf("%d%d%d",&n,&s,&p)!=EOF)
{
memset(e,0,sizeof(e));
for(int i=1;i<=s;i++)
e[i].id=i;
for(int i=1;i<=n;i++)
{
int num=0;
memset(vis,0,sizeof(vis));
for(int j=1;j<=s;j++)
{
int k;
scanf("%d",&k);
if(k==0)
num++;
else vis[j]=1;
}
for(int j=1;j<=s;j++)
{
if(vis[j])
{
e[j].score+=num;
}
}
}
std::sort(e+1,e+s+1,cmp);
int ans1,ans2;
for(int i=1;i<=s;i++)
{
if(e[i].id==p)
{
ans1=e[i].score;
ans2=i;
}
}
printf("%d %d\n",ans1,ans2);
}
}

1. Often We don’t set up on weblogs, but I would like to condition that this established up really forced me individually to do this! considerably outstanding publish

2. 问题3是不是应该为1/4 .因为截取的三段，无论是否能组成三角形， x， y-x ，1-y,都应大于0，所以 x<y,基础应该是一个大三角形。小三角是大三角的 1/4.

3. #include <cstdio>
#include <cstring>

const int MAXSIZE=256;
//char store[MAXSIZE];
char str1[MAXSIZE];
/*
void init(char *store) {
int i;
store['A']=’V', store['B']=’W',store['C']=’X',store['D']=’Y',store['E']=’Z';
for(i=’F';i<=’Z';++i) store =i-5;
}
*/
int main() {
//freopen("input.txt","r",stdin);
//init(store);
char *p;
while(fgets(str1,MAXSIZE,stdin) && strcmp(str1,"STARTn")==0) {
if(p=fgets(str1,MAXSIZE,stdin)) {
for(;*p;++p) {
//*p=store[*p]
if(*p<’A’ || *p>’Z') continue;
if(*p>’E') *p=*p-5;
else *p=*p+21;
}
printf("%s",str1);
}
fgets(str1,MAXSIZE,stdin);
}
return 0;
}

4. 5.1处，反了；“上一个操作符的优先级比操作符ch的优先级大，或栈是空的就入栈。”如代码所述，应为“上一个操作符的优先级比操作符ch的优先级小，或栈是空的就入栈。”