标签:sicily
Time Limit: 1 secs, Memory Limit: 256 MB , Special Judge
There are n children in a country marked by integers from 1 to n.
The first line contains a integer n which is between 1 and 1000. The following n lines contains n characters respectively. Character is either ‘0‘ or ‘1‘. The Bth character of (A+1)th line will be ‘1‘ if and only if A can beat B. Input is terminated by EOF.
A number representing a king of children on a line. If such a king does not exist, output -1. If there are multiple kings, any one is accepted.
2 01 00
1
每周一赛:2010中山大学新手赛
#include <stdio.h> int main() { int n, i, j, temp_num, king, max; char temp[1000]; while (~scanf("%d\n", &n)) { for (i = 0, max = 0, king = 0; i < n; i++) { gets(temp); for (j = 0, temp_num = 0; j < n; j++) { if (temp[j] == '1') temp_num++; } if (temp_num > max) { max = temp_num; king = i; } } printf("%d\n", king + 1); } return 0; }
标签:sicily
原文地址:http://blog.csdn.net/u012925008/article/details/44739479