UPC2218: Thrall’s Dream

网友投稿 239 2022-11-30

UPC2218: Thrall’s Dream

2218: Thrall’s Dream

Time Limit: 1 Sec   Memory Limit: 128 MB

Submit: 253

Solved: 72

[

​​Submit​​][

​​Status​​][

​​Web Board​​]

Description

We never paid any heed to the ancient prophecies, like fools we clung to the old hatreds, and fought as we had for generations. Until one day the sky rained fire, and a new enemy came upon us. We stand now upon the brink of destruction, for the Reign of Chaos has come at last.

Thrall, the warchief of the Orcish Horde, all along, he led his tribe live in the fringe of Lordaeron under the human control. In a downpour night, Thrall falls into sleep in a Orc hall at Arathi Highlands, at this moment he heard a voice:

“The sands of time have run out, son of Durotan. The cries of war echo upon the winds, the remnants of the past scar the land which is besieged once again by conflict. Heroes arise to challenge fate, and lead their brethren to battle. As mortal armies rush blindly towards their doom, The Burning Shadow comes to consume us all. You must rally the Horde, and lead your people to their destiny.

I will answer all of your questions in time, young warchief. For now, rally your warriors and prepare to leave this land, cross the sea to the distant land of Kalimdor. We will speak again. ”

Thrall believes the prophesy of Blood Raven Medivh. Three days later, He and Grom Hellscream's Warsong Clan meet in the Lordaeron coast to the distant lands of Kalimdor. But the Goblin Zeppelins they take encountered storms in the middle. Thrall and Grom falling to the islands, they want to find each other and then to Kalimdor.

For the sake of simplicity, we assume that Thrall and Grom may fall into any islands x and y, only by Thrall to find Grom or by Grom to find Thrall. Give you the map of this island, please judge that Thrall and Gtom can meet?

Input

There are multiple test case in the input file, first line is a case number T. Each test case will begin with two integers N (0 <= N < 2001) and M (0 <= M < 10001), where N is the number of islands and M is number of portal. Next M lines each line contains two integers a and b, indicated there is a portal in island a that people can go from a to b by this portal. The island numbered from 1 to N.

Output

For each test case, your output should be in one line with “Kalimdor is just ahead” (without quotes, hereinafter the same) if Thrall and Grom can meet or “The Burning Shadow consume us all” otherwise as indicated in the sample output.

Sample Input

23 21 21 33 21 22 3

Sample Output

Case 1: The Burning Shadow consume us allCase 2: Kalimdor is just ahead

HINT

Source

​​2013年山东省第四届ACM大学生程序设计竞赛​​

#include#include#include#include#include#include#include/**********是清空数组用的,开始因为没有加清空WA了好多次**********/using namespace std;//这个一定要写在最前面const int maxn = 2005;vector g[maxn];//用来存储输入的有向边bool can[maxn][maxn];//用一个bool的二维数组来判断是否连通int N,M;bool ok()//最后用来判断的数组,已经把有向边连通的边存到了里面{ for(int i=1;i<=N;i++) { for(int j=i+1;j<=N;j++) if(!can[i][j] && !can[j][i])//如果i和j 还有j和i都不能连通的话,就反回false return false; } return true;}void bfs(int x)///bfs///{ queue que; ///队列,用来存放先入的一个节点(这个节点就是x),以及这个节点连通的点 ///如果有比这个节点大的连通,也就是与x连通的节点比x大,那么也会存放到队列里,在去找连通点 que.push(x);//出队 while(!que.empty()) { short q = que.front(); que.pop();///每次的q就是当前活跃的节点,寻找与当前q连通的点 if(q>T; while(T--) { cin>>N>>M; for(int i=1;i<=N;i++) g[i].clear(); while(M--) { int a,b; cin>>a>>b; g[a].push_back(b); } memset(can,0,sizeof(can)); for(int i=1;i<=N;i++) bfs(i); cout<<"Case "<

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java 集合框架之List 的使用(附小游戏练习)
下一篇:sdut2411 Pixel density
相关文章

 发表评论

暂时没有评论,来抢沙发吧~