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. Navicat for MySQL笔记1

    1.MySQL数据库的基本操作 A.系统数据库 安装MySQL数据库服务器后,自带的数据库. B.用户数据库 用户根据实际需求所创建的数据库. C.数据库对象 表.视图.存储过程.函数.触发器以及事件 ...

  2. matlab的应用

    MATLAB在信号与系统中的应用 一: 看到MATLAB在信号与系统中的应用,对这部分我比较熟悉,在此举一个小例子.    impulse(sys)表示求连续系统sys的冲击响应    subplot ...

  3. PAT 1053 住房空置率

    https://pintia.cn/problem-sets/994805260223102976/problems/994805273284165632 在不打扰居民的前提下,统计住房空置率的一种方 ...

  4. vsftpd的配置文件说明

    vsftpd的配置文件说明: vsftpd.ftpusers:位于/etc目录下.它指定了哪些用户账户不能访问FTP服务器,例如root等. vsftpd.user_list:位于/etc目录下.该文 ...

  5. PHP 中各种命名规则的总结

    一般约定而言 类.函数和变量的名字应该是能够让代码阅读者能够容易地知道这些代码的作用,应该避免使用凌磨两可的命名. 以下是在开发过程中常见的命名规则总结 1.类的命名 使用大写字母作为词的分割,其余的 ...

  6. Read N Characters Given Read4

    The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...

  7. ACM数论之旅13---容斥原理(一切都是命运石之门的选择(=゚ω゚)ノ)

    容斥原理我初中就听老师说过了,不知道你们有没有听过(/≧▽≦)/ 百度百科说: 在计数时,必须注意没有重复,没有遗漏. 为了使重叠部分不被重复计算,人们研究出一种新的计数方法. 这种方法的基本思想是: ...

  8. Ubuntu和Windows相互共享文件夹

    一.Ubuntu访问Windows共享文件夹 1.对需要共享文件夹右击->属性->共享 2.选择要与其共享的用户,选择好用户点击有点添加按钮添加,然后点击下方的共享按钮 3.完成共享 4. ...

  9. jenkins自动部署windwos服务器

    jenkins 持续构建windows 项目 需求说明 公司新购windwos服务器,并配置了堡垒机,由于经常要提交代码进行更新,导致手动部署很是麻烦,故采用公司jenkins实行持续构建 jenki ...

  10. Java IO流学习总结 - BIO

      Java流操作有关的类或接口: Java流类图结构: 流的概念和作用 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据 ...