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 Bth 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. If there are multiple kings, any one is accepted.

Sample Input
 Copy sample input to clipboard
2
01
00
Sample Output
1

给跪了,这个题目,一开始就知道了找出最大度的点。但频频WA,蛋疼。然后用DFS,Warshall都试了。甚至出现TLE,结果排了一个小时错,发现是index没有初始化就一直WA,我真心给跪了。。。。这个我觉得真没什么意义。但处于规范,还是加下吧。。。。。。

代码如下:

#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
string King;
int i,j;
int out;
while(cin >> N)
{
int max = 0;
int index = 0; //这里没有初始化就一直WA
for(i = 0;i < N;i++)
{
cin >> King;
out = 0;
for(j = 0;j < N;j++)
{
if(King[j] == '1')
out++;
}
if(max < out)
{
max = out;
index = i;
}
}
cout << index + 1 << endl;
}
return 0;
}

soj2012.King(有向图+蛋疼得一逼)的更多相关文章

  1. Openssl 升级操作

    转自:http://www.cnblogs.com/lzcys8868/p/9235538.html 首先我觉得没事就用绿盟扫漏洞的公司,就是闲的蛋疼,傻逼!不少服务器使用nginx,如果openss ...

  2. [javaSE] 看知乎学习反射

    简单的来说,反射机制指的是程序在运行时能够获取自身的信息.在java中,只要给定类的名字,那么就可以通过反射机制来获得类的所有信息. 知乎:学习java应该如何理解反射?   余晖: 反射提供了一种运 ...

  3. openssl 升级操作 -2

    首先我觉得没事就用绿盟扫漏洞的公司,就是闲的蛋疼,傻逼!不少服务器使用nginx,如果openssl 是静态编译的,直接将openssl 编译到nginx里面去了,这就意味着,单纯升级openssl ...

  4. unreal3启动地图设置

    在defaultengine.ini中[URL]节: Map=MOBATinyMap.udkLocalMap=MOBATinyMap.udk 这里有Map和LocalMap两个属性,让人有点混淆,只好 ...

  5. cdoj 93 King's Sanctuary 傻逼几何题

    King's Sanctuary Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sho ...

  6. King's Quest —— POJ1904(ZOJ2470)Tarjan缩点

    King's Quest Time Limit: 15000MS Memory Limit: 65536K Case Time Limit: 2000MS Description Once upon ...

  7. BZOJ-1087 互不侵犯King 状压DP+DFS预处理

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2337 Solved: 1366 [Submit][ ...

  8. 十三篇系列:king转折点,wooga瓶颈,supercell营收结构

    转自:http://gamerboom.com/archives/95125 十三篇系列:king的历史转折点,wooga的瓶颈,supercell的营收结构 第一篇 这句话In other word ...

  9. HDU 3861.The King’s Problem 强联通分量+最小路径覆盖

    The King’s Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

随机推荐

  1. 0422数学口袋精灵bug发现

    团队成员的博客园地址: 蔡彩虹:http://home.cnblogs.com/u/caicaihong/ 曾治业:http://www.cnblogs.com/zzy999/ 蓝叶:http://w ...

  2. XLSReadWriteII5使用示例

    之前一直是使用XLSReadWriteII4,今天更新到XLSReadWriteII5,测试了一下,发现一些操作变化比较大,现将XLSReadWriteII5的使用示例写一下,以下是代码和生成的exc ...

  3. Js 中的原始值和引用值

    最近遇写 node.js 时到一个问题,把对象当赋值给数组成员时总是出错,比如下面的代码, var Arr = new Array(); var Obj = new Object(); for(var ...

  4. CSS 报错

  5. Redis(一) 安装

    选择在Linux下安装redis,现在采用虚拟机安装的centos7 进行安装的 1.安装gcc yum install gcc-c++ 2.下载redis安装包,在root目录下执行 wget ht ...

  6. input accept 属性

    *.3gpp audio/3gpp, video/3gpp 3GPP Audio/Video *.ac3 audio/ac3 AC3 Audio *.asf allpication/vnd.ms-as ...

  7. delphi手动创建dataset并插入值

    unit Unit1; interface uses  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syste ...

  8. java super

    用法: 1.子类构造器里面默认调用父类构造器 2.调用父类的属性,方法

  9. Robot Framework 的安装配置和简单的实例介绍

    Robot Framework 介绍 Robot Framework 是一款基于 Python 的功能自动化测试框架.它具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型的客户端或者接口,可以进 ...

  10. 不记得oracle管理员密码,更改oracle sys密码的方法

    1.确保下面两条满足 a. sqlnet.ora里 SQLNET.AUTHENTICATION_SERVICES = (NTS) 的配置是否存在,不存在加上这句: b. 你的os 用户是不是属于ora ...