CCF CSP 資料中心

2021-09-13 22:35:53 字數 2864 閱讀 7045

試題編號: 201812-4

試題名稱: 資料中心

時間限制: 1.0s

記憶體限制: 512.0mb

問題描述:

樣例輸入45

11 2 3

1 3 4

1 4 5

2 3 8

3 4 2

樣例輸出

樣例說明

下圖是樣例說明。

雖然題目說的很複雜,但是仔細觀察樣例後發現,其實就是乙個最小生成樹的問題,甚至都不需要考慮根節點在什麼位置,因為無論在什麼位置,只要把最小生成樹求出來,問題就是符合題目要求的。

**1:寫cmp函式,不使用容器

#include

using

namespace std;

#define max 100001

#define maxn 500001

struct edge

;edge

(int u1,

int v1,

int w1):u

(u1),v

(v1),w

(w1)};

int pre[maxn]

;edge edge[max]

;bool

cmp(edge e1, edge e2)

intfind

(int root)

while

(son != root)

return root;

}bool

join

(int x,

int y)

return

false;}

intmain()

for(i=

0; i

)sort

(edge, edge+m, cmp)

;for

(i=0

; i} cout << ans << endl;

return0;

}

**2:過載 < 運算子,不使用容器
#include

using

namespace std;

#define max 100001

#define maxn 500001

struct edge

;edge

(int u1,

int v1,

int w1):u

(u1),v

(v1),w

(w1)

bool

operator

<

(struct edge &e1)};

int pre[maxn]

;edge edge[max]

;int

find

(int root)

while

(son != root)

return root;

}bool

join

(int x,

int y)

return

false;}

intmain()

for(i=

0; i

)sort

(edge, edge+m, cmp)

;for

(i=0

; i} cout << ans << endl;

return0;

}

**3:過載 < 運算子,使用容器
#include

using

namespace std;

struct edge

edge

(int u1,

int v1,

int w1):u

(u1),v

(v1),w

(w1)

bool

operator

<

(struct edge &e1)};

const

int maxn =

500001

;const

int maxm =

100001

;int pre[maxn]

;vector edge;

intfindx

(int root)

while

(son != root)

return root;

}int

join

(int root1,

int root2)

return

false;}

intmain()

for(i=

0; i

)sort

(edge.

begin()

, edge.

end())

;for

(vector

::iterator it = edge.

begin()

; it != edge.

end(

); it++)}

}return0;

}

CCF CSP 201812 4 資料中心

題目的意思說白了就是找到乙個最小值k,使得用小於等於k的邊組成的圖是聯通的即可。二分這個k判定下就好了。第二種做法就是求mst裡面的最大邊就是答案。includeusing namespace std define pii pair define mp make pair const int max...

資料中心與雲資料中心

資料中心與雲資料中心 資料中心 dc,datacenter 是指在乙個物理空間內實現資訊的集中處理 儲存 傳輸 管理等功能,它包括伺服器 儲存 網路等關鍵裝置和這些關鍵裝置執行所需要的環境因素,如供電 製冷 消防 監控等關鍵基礎設施。雲資料中心是一種基於雲計算架構的,計算 儲存及網路資源松耦合,完全...

雲資料中心與傳統資料中心

雲資料中心是一種基於雲計算架構的,計算 儲存及網路資源松耦合,完全虛擬化各種it裝置 模組化程度較高 自動化程度較高 具備較高綠色節能程度的新型資料中心。雲資料中心的特點 高度的虛擬化,這其中包括伺服器 儲存 網路 應用等虛擬化,使使用者可以按需呼叫各種資源 自動化管理程度,包括對物理伺服器 虛擬伺...