日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Thrall’s Dream HRBUST - 2048【BFS or 强连通分量】

發(fā)布時(shí)間:2024/2/28 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Thrall’s Dream HRBUST - 2048【BFS or 强连通分量】 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

立志用最少的代碼做最高效的表達(dá)


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
2
3 2
1 2
1 3
3 2
1 2
2 3
Sample Output
Case 1: The Burning Shadow consume us all
Case 2: Kalimdor is just ahead


分析

題意:n個(gè)點(diǎn),m條路,單向路(只能從a到b)。 問(wèn)任意兩個(gè)點(diǎn)是否都連通。

分析

1、BFS
模板題,開(kāi)大數(shù)組存儲(chǔ)全部點(diǎn),最后判斷即可。

2、強(qiáng)聯(lián)通分量
明天更新~


代碼一:BFS解法

#include<iostream> #include<queue> #include<cstring> #define maxn 2010 using namespace std; typedef long long gg;gg n, m; vector<gg>g[maxn]; bool has[maxn][maxn]; //連通數(shù)組 bool vis[maxn]; //每次bfs時(shí)判斷是否可見(jiàn) bool ok;void bfs(int s) {memset(vis, 0, sizeof(vis)); //vis置0 vis[s] = 1;queue<int>q;q.push(s);while(!q.empty()) { //遍歷數(shù)組 int first = q.front();q.pop();int len = g[first].size();for(int i = 0; i < len; i++) {int v = g[first][i];if(vis[v]) continue; //如果已經(jīng)遍歷過(guò),則跳過(guò)has[s][v] = 1;q.push(v);vis[v] = 1; }} }int main() {gg t, c = 1;scanf("%lld", &t);while(t--) {ok = true;scanf("%lld%lld", &n, &m);memset(has, 0, sizeof(has)); //1、初始化 for(gg i = 0; i < maxn; i++) g[i].clear();gg u, v;while(m--) { //2、數(shù)值存儲(chǔ), scanf("%lld%lld", &u, &v);g[u].push_back(v);}for(gg i = 1; i <= n; i++) //3、逐個(gè)bfs,生成has數(shù)組 bfs(i);for(int i = 1; i <= n; i++) { //判斷是否連通 for(int j = i+1; j <= n; j++) {if(!has[i][j] && !has[j][i]) { //只要有一個(gè)不連通 ok = false; break;}}if(ok == false) break;} if(ok)printf("Case %d: Kalimdor is just ahead\n", c++);else printf("Case %d: The Burning Shadow consume us all\n",c++);}return 0; }

耗時(shí)

500ms

超強(qiáng)干貨來(lái)襲 云風(fēng)專訪:近40年碼齡,通宵達(dá)旦的技術(shù)人生

總結(jié)

以上是生活随笔為你收集整理的Thrall’s Dream HRBUST - 2048【BFS or 强连通分量】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 中文字幕 国产精品 | 伊人网在线免费观看 | 开心激情网五月天 | 久久av影院 | 男人日女人免费视频 | 在线三区 | 国产精品久久久99 | 97成人在线视频 | 波多野42部无码喷潮 | 91精品国产91久久久久青草 | 亚洲国产精品综合 | 中文字幕精品一区二 | 樱桃香蕉视频 | 国产福利小视频在线 | 91视频最新入口 | 中文字字幕在线中文 | 一级毛片aa | 吸咬奶头狂揉60分钟视频 | 欧美另类在线观看 | 日本网站在线免费观看 | 美女被叉叉的影院 | 国产电影一区二区三区爱妃记 | 重囗味sm一区二区三区 | 国产又黄又猛的视频 | 爽妇网国产精品 | 四季av国产一区二区三区 | 天天射天天干天天操 | 99热思思 | 91成人精品| 污污的视频在线观看 | h片免费观看 | 久久精品色欲国产AV一区二区 | 亚洲操操操 | 日韩精品免费播放 | 少妇被黑人到高潮喷出白浆 | 国产成人在线一区二区 | 91成人久久| 国产精品自产拍在线观看 | 999热 | 欧美第一网站 | 久久视频在线观看免费 | 香蕉久久夜色精品升级完成 | www.777奇米影视 | 日韩高清影视在线观看 | 亚洲精品久久久久久久久久 | 日本一级三级三级三级 | 黄色大片aa | 韩国美女黄色片 | 91亚洲国产成人久久精品网站 | 人人澡人人澡人人澡 | 午夜寂寞影视 | 激情成人综合网 | 亚洲在线影院 | 国产第8页 | 国产精品美女久久久网av | 久草观看视频 | 动漫av一区二区三区 | 韩国av电影在线观看 | 亚洲综合婷婷久久 | 久久国产精品免费看 | 一区三区视频在线观看 | 亚洲精品男人的天堂 | 欧美精品不卡 | 翔田千里88av中文字幕 | 午夜日韩福利 | 777奇米四色 | 免费无遮挡无码永久视频 | 精品欧美一区二区久久久 | 瑟瑟综合网 | 亚洲一区在线免费 | 亚洲欧美一区二区三区情侣bbw | 伊人影院久久 | 台湾swag在线观看 | 国产免费一区二区三区三州老师 | 日本老妇性生活 | 午夜草草 | 91久久久久久久 | 精品国产免费一区二区三区 | 四季av日韩精品一区 | 香蕉久久网| 精品99久久久久成人网站免费 | 美女网站av | 人妻精品一区一区三区蜜桃91 | 日本动漫艳母 | 91热爆视频| 国产视频二区三区 | 日韩福利视频网 | 国产视频一二区 | 黄色网页在线播放 | 东北少妇露脸无套对白 | 亚洲资源在线播放 | 久久接色| 欧美草草| 欧美熟妇久久久久 | 欧美乱妇在线观看 | 亚洲香蕉在线观看 | 国产亚洲精久久久久久无码苍井空 | 91精品婷婷国产综合久久蝌蚪 | 亚洲欧美乱日韩乱国产 |