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. Linux_Apache 安装

    1.下载依赖扩展 apr.apr-util.pcre(正则依赖) https://apr.apache.org/download.cgi#aprutil1 apr:http://mirrors.shu ...

  2. Java容器深入浅出之PriorityQueue、ArrayDeque和LinkedList

    Queue用于模拟一种FIFO(first in first out)的队列结构.一般来说,典型的队列结构不允许随机访问队列中的元素.队列包含的方法为: 1. 入队 void add(Object o ...

  3. 重新认识javascript的settimeout和异步

    1.简单的settimeout setTimeout(function () { while (true) { } }, 1000); setTimeout(function () { alert(' ...

  4. BZOJ5286 HNOI/AHOI2018转盘(分块/线段树)

    显然最优走法是先一直停在初始位置然后一次性走完一圈.将序列倍长后,相当于找一个长度为n的区间[l,l+n),使其中ti+l+n-1-i的最大值最小.容易发现ti-i>ti+n-(i+n),所以也 ...

  5. Scrapy初尝试

    ,python3.6版本 在看网上的安装的时候下一堆依赖,其实没有必要一个个的去装,pip直接分析依赖一块下载安装下来! 已经安装了pip模块 直接上 pip install scrapy 安装twi ...

  6. Extend to Palindrome UVA - 11475(补成回文串)

    题意: 就是用最少的字符把原字符串补成回文串 解析: emm/.../网上都是用kmp和后缀数组做的 我没想到这俩的思路...emmm... 想到了exkmp的  就是原串和逆串匹配一下  注意要保证 ...

  7. [CF850F] Rainbow Balls

    题目大意 这里 题解 我们枚举最后剩下的球的种类,那么其他球可以看做没用了. 设选定的球有\(a_i\)个,球的总数为\(s=\sum_{i=1}^n a_i\). 现在问题变为:在一个长度为\(s\ ...

  8. [AT2384] [agc015_f] Kenus the Ancient Greek

    题目链接 AtCoder:https://agc015.contest.atcoder.jp/tasks/agc015_f 洛谷:https://www.luogu.org/problemnew/sh ...

  9. Mysql向数据库插入数据时,判断是否存在,若不存在就插入数据

    表中一定要有主键  : select :id,此处的id位置处必须是主键 insert into table_name(id, name, password) select :id, :name, : ...

  10. bzoj 1017 : [JSOI2008]魔兽地图DotR

    比较难想的的一道树形dp. 看到这道题正常的思路应该是$f[i][j][k]$表示i这棵子树里买了j个i物品花费为k的最大收益. 但如果直接这么定义的话转移复杂度会很高,需要枚举j,枚举孩子,枚举k, ...