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. Mac下不能安装第三方下载软件

    1.安装成功后,启动时如提示“某某文件已损坏,打不开”,请将电脑的“系统偏好设置--安全性与隐私--通用”的允许从以下位置下载的应用程序设置为“任何来源”. 2.如果您的电脑上没有“任何来源”的选项, ...

  2. iOS 判断当前app版本,升级

    要获取当前app store上的最新的版本,有两种方法, 一.在某特定的服务器上,发布和存储app最新的版本信息,需要的时候向该服务器请求查询. 二.从app store上查询,可以获取到app的作者 ...

  3. 累计进度条 PSP 饼图

    累计进度条   PSP   饼图 每周例行报告 本周PSP 类别 任务 开始时间 结束时间 被打断时间 总计工作时间 2016年9月24日 读书 构建之法-6.7章 19:00 20:00 2 58m ...

  4. xshell 常用快捷键

    1.连接mysql数据库mysql -uroot -p -h127.0.0.1 -P3306 2.列出所有sessionshow full processlist; 3.查看20条执行时间最长的SQL ...

  5. 树莓派安装、卸载docker

    1.下载安装脚本(官方说明的是不能使用debian的系统的安装方式安装): curl -fsSL get.docker.com -o get-docker.sh 2.安装: sudo sh get-d ...

  6. django中使用FastDFS分布式文件系统接口代码实现文件上传、下载、更新、删除

    运维使用docker部署好之后FastDFS分布式文件系统之后,提供给我接口如下: fastdfs tracker 192.168.1.216 192.168.1.217 storage 192.16 ...

  7. Hplsql报错:...HiveSQLExpection:Error while compiling statement:No privilege 'Select' found for inputs {.....}

    实践hplsql时,遇到的问题总结一下,若有不对的地方,欢迎交流. 一.Hplsql简介 hplsql的介绍详见:http://lxw1234.com/archives/2015/09/492.htm ...

  8. 【Cf Edu #47 G】Allowed Letters

    这个题大概就是每一个位置都有一个能填字符的限制(一个点集),给出已有的$n$个字符,问能填出的最小字典序的字符串. 总体思路是贪心,每一位尽量选最小的字符. 关键在于判断在某位选了一个字符后,接下来的 ...

  9. ZABBIX 3.4 监控Nginx 状态(七)

    一.环境准备 1.在nginx的配置文件中,添加status配置        location /nginx_status {               stub_status on;       ...

  10. 一次绕过防火墙获取RCE以及提权到root权限的渗透过程

    本文是关于Apache struts2 CVE-2013-2251是由于导致执行远程命令的影响而被高度利用的漏洞.简而言之, 通过操纵以“action:”/”redirect:”/”redirectA ...