22158_King

2022-5-16 18:21| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506160517800-Problem List-采集的数据-后羿采集器.html

Pro.ID

22158

Title

King

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22158

AC

0

Submit

9

Ratio

0.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    There are n children in a country marked by integers from 1 to n.

    They often fight with each other. For each pair of child A and child B, either A beats B or B beats A. It is not possible that both A beats B and B beats A. Of course, one never fight with himself.

    Child A is not afraid of child B if A can beat B.

    Child A is not afraid of child B if A can beat C and C can beat B either. Because A can say "I will call C to beat you" to B.

    A child is called a king of children if he is not afraid of any other child.

    Give you the beating relations. Find a king.

    输入

    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 B-th character of (A+1)-th line will be '1' if and only if A can beat B. Input is terminated by EOF.

    输出

    Description

    There are n children in a country marked by integers from 1 to n.

    They often fight with each other. For each pair of child A and child B, either A beats B or B beats A. It is not possible that both A beats B and B beats A. Of course, one never fight with himself.

    Child A is not afraid of child B if A can beat B.

    Child A is not afraid of child B if A can beat C and C can beat B either. Because A can say "I will call C to beat you" to B.

    A child is called a king of children if he is not afraid of any other child.

    Give you the beating relations. Find a king.

    Input

    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 B-th character of (A+1)-th line will be '1' if and only if A can beat B. Input is terminated by EOF.

    Output

    A number representing a king of children on a line. If such a king does not exist, output -1.

    Sample Input

    2
    01
    00

    Sample Output

    1

    Source

    样例输入

    2
    01
    00

    样例输出

    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部