int judge() { int v[13] = { 0 }; queue<int> myq; myq.push(ans[0]); v[ans[0]] = 1; while (!myq.empty()) { int t = myq.front(); myq.pop(); for (int i = 1; i < 5; i++) { if (c[t][ans[i]] == 1 && v[ans[i]] == 0) { myq.push(ans[i]); v[ans[i]]…
题目链接: India and China Origins Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 685 Accepted Submission(s): 230 Problem Description A long time ago there are no himalayas between India and Chi…
在图论中,连通图基于连通的概念.在一个无向图 G 中,若从顶点vi到顶点vj有路径相连(当然从vj到vi也一定有路径),则称vi和vj是连通的.如果 G 是有向图,那么连接vi和vj的路径中所有的边都必须同向.如果图中任意两点都是连通的,那么图被称作连通图.如果此图是有向图,则称为强连通图(注意:需要双向都有路径).图的连通性是图的基本性质. 严格定义(摘抄): 对一个图 G=(V,E) 中的两点 x 和 y ,若存在交替的顶点和边的序列 Γ=(x=v0-e1-v1-e2-...-ek-(v…
题目传送门 题意:一个人从(0, 0)逃往(n, m),地图上有朝某个方向开炮的炮台,问最少逃脱步数 分析:主要在状态是否OK,当t时刻走到(x,y),炮台是否刚好打中,因为只能是整数,所以用整除判断.题意不清楚,有些坑点. #include <bits/stdc++.h> using namespace std; const int N = 1e2 + 5; struct Point { int dir, t, v; //N 1 E 2 S 3 W 4 }p[N][N]; struct No…
诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 14267 Accepted Submission(s): 3638 Problem Description Hogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖…
题目链接: C. NP-Hard Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem ve…
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string…
You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to travel in the country is taking planes. Strangely, in this strange country, for every two cities A and B, there is a flight fro…
2013-09-08 09:48 最大生成树,输出生成树中最短的边儿即可 或者对边儿排序,二份答案+BFS判断是否1连通N 时间复杂度都是O(NlogN)的 附最大生成树pascal代码 //By BLADEVIL var m, n, t :longint; pre, other, len :array[0..101000] of longint; father :array[0..100100] of longint; i :longint; procedure init; var i :lo…
Bubble Shooter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 596 Accepted Submission(s): 239 Problem Description Bubble shooter is a popular game. You can find a lot of versions from the I…
题目如下: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root. Input Specificat…
Problem Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this board is consisting of grass or just empty and then they start to fire all the grass. Firstl…
E. Bear and Forgotten Tree 2 题目连接: http://www.codeforces.com/contest/653/problem/E Description A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n. Limak is a little polar bear. He once…
Fire! Time Limit: 5000MS Memory Limit: 262144KB 64bit IO Format: %lld & %llu Description Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe esca…