博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3224 Go for Lab Cup!(我的水题之路——赢的场数最多)
阅读量:4068 次
发布时间:2019-05-25

本文共 2134 字,大约阅读时间需要 7 分钟。

Go for Lab Cup!
Time Limit: 1000MS   Memory Limit: 131072K
Total Submissions: 7697   Accepted: 3946

Description

The Lab Cup Table Tennis Competition is going to take place soon among laboratories in PKU. Students from the AI Lab are all extreme enthusiasts in table tennis and hold strong will to represent the lab in the competition. Limited by the quota, however, only one of them can be selected to play in the competition.

To make the selection fair, they agreed on a single round robin tournament, in which every pair of students played a match decided by best of 5 games. The one winning the most matches would become representative of the lab. Now Ava, head of the lab, has in hand a form containing the scores of all matches. Who should she decide on for the competition?

Input

The input contains exactly one test case. The test case starts with a line containing n (2 ≤ n ≤ 100), the number of students in the lab. Then follows an n × n matrix A. Each element in the matrix will be one of 0, 1, 2 and 3. The element at row i and column jaij, is the number of games won by the ith student in his/her match with the jth student. Exactly one of aij and aji (i ≠ j) is 3 and the other one will be less than 3. All diagonal elements of the matrix are 0’s.

Output

Output the number of the student who won the most matches. In the case of a tie, choose the one numbered the smallest.

Sample Input

40 0 3 23 0 3 12 2 0 23 3 3 0

Sample Output

4

Source

, ideas from ava, text and test cases by frkstyc
北大实验室要招人,就举办了比赛,n个人循环赛,如果赢了一场比赛就赢3分,否则获得不一定的分数。现在问谁赢得的比赛场数最多。
直接每行取分,如果是3分就+1,比较出获得3分最多的人,输出号码(从1开始)。
注意点:
1)不是算比分最高,而是得到3分的次数最多
代码(1AC):
#include 
#include
int main(void){ int n; int max, maxi, sum, tmp; int i, j; while (scanf("%d", &n) != EOF){ for (i = 1, max = -1; i <= n; i++){ for (j = 1, sum = 0; j <= n; j++){ scanf("%d", &tmp); if (tmp == 3){ sum ++; } } if (sum > max){ max = sum; maxi = i; } } printf("%d\n", maxi); } return 0;}

转载地址:http://aloji.baihongyu.com/

你可能感兴趣的文章
Java-IO-java的IO流
查看>>
Java-IO-输入/输出流体系
查看>>
Java实现DES加密解密
查看>>
HTML基础
查看>>
Java IO
查看>>
Java NIO
查看>>
Java大数据:Hbase分布式存储入门
查看>>
Java大数据:全文搜索引擎Elasticsearch入门
查看>>
大数据学习:Hadoop入门学习书单
查看>>
大数据学习:Spark SQL入门简介
查看>>
大数据学习:Spark RDD操作入门
查看>>
大数据框架:Spark 生态实时流计算
查看>>
大数据入门:Hive和Hbase区别对比
查看>>
大数据入门:ZooKeeper工作原理
查看>>
大数据入门:Zookeeper结构体系
查看>>
大数据入门:Spark RDD基础概念
查看>>
大数据入门:SparkCore开发调优原则
查看>>
大数据入门:Java和Scala编程对比
查看>>
大数据入门:Scala函数式编程
查看>>
【数据结构周周练】002顺序表与链表
查看>>