正文
增加 8 行删除 8 行
41 行未改动42434445464748495028 行未改动79808182838485868739 行未改动12712812913013113213313413549 行未改动18518618718818919019119219314 行未改动2082092102112122132142152163 行未改动22022122222322422522622722845 行未改动27427527627727827928028128238 行未改动32132232332432532632741 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}//----------------------并查集模版-------------------bool cmp(Edge A,Edge B){return A.w<B.w;28 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```## P1194 买礼物此题我的思路有些不同39 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}//----------------------并查集模版-------------------void add_edge(int u,int v,int w){e[++idx]={u,v,w};49 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```## P2916 [USACO08NOV Cheering up the Cow G这题我们就需要手推样例了14 行未改动$c_4 + l_7 + c_5 + l_7 + c_4 + l_3 + c_2 + l_2 + c_3 + l_2 + c_2 + l_1 + c_1 + l_1 + c_2 + l_3 + c_4$可以简化成:$c_4 + 2 \times l_7 + c_5 + 2 \times c_4 + 2 \times l_3 + 3 \times c_2 + 2 \times l_2 + c_3 + 2 \times l_1 + c_1$上面加起来就是 176我们如果第二步不去 5 而去 2 呢(但是经过的边不变)3 行未改动$c_4 + l_3 + c_2 + l_1 + c_1 + l_1 + c_2 + l_2 + c_3 + l_2 + c_2 + l_3 + c_4 + l_7 + c_5 + l_7 + c_4$可以简化成:$c_4 + 2 \times l_7 + c_5 + 2 \times c_4 + 2 \times l_3 + 3 \times c_2 + 2 \times l_2 + c_3 + 2 \times l_1 + c_1$和第一个路径一模一样我们把初始节点换成 5 经过边不变,再跑一次45 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}bool cmp(Edge A,Edge B){return A.w<B.w;}38 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```##41 行未改动42434445464748495028 行未改动79808182838485868739 行未改动12712812913013113213313413549 行未改动18518618718818919019119219314 行未改动2082092102112122132142152163 行未改动22022122222322422522622722845 行未改动27427527627727827928028128238 行未改动32132232332432532632741 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}//----------------------并查集模版-------------------bool cmp(Edge A,Edge B){return A.w<B.w;28 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```## P1194 买礼物此题我的思路有些不同39 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}//----------------------并查集模版-------------------void add_edge(int u,int v,int w){e[++idx]={u,v,w};49 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```## P2916 [USACO08NOV Cheering up the Cow G这题我们就需要手推样例了14 行未改动$c_4 + l_7 + c_5 + l_7 + c_4 + l_3 + c_2 + l_2 + c_3 + l_2 + c_2 + l_1 + c_1 + l_1 + c_2 + l_3 + c_4$可以简化成:$c_4 + 2 \times l_7 + c_5 + 2 \times c_4 + 2 \times l_3 + 3 \times c_2 + 2 \times l_2 + c_3 + 2 \times l_1 + c_1$上面加起来就是 176我们如果第二步不去 5 而去 2 呢(但是经过的边不变)3 行未改动$c_4 + l_3 + c_2 + l_1 + c_1 + l_1 + c_2 + l_2 + c_3 + l_2 + c_2 + l_3 + c_4 + l_7 + c_5 + l_7 + c_4$可以简化成:$c_4 + 2 \times l_7 + c_5 + 2 \times c_4 + 2 \times l_3 + 3 \times c_2 + 2 \times l_2 + c_3 + 2 \times l_1 + c_1$和第一个路径一模一样我们把初始节点换成 5 经过边不变,再跑一次45 行未改动void unite(int x,int y){int rootx=find(x);int rooty=find(y);if(rootx!=rooty)pre[rootx]=rooty;return ;}bool cmp(Edge A,Edge B){return A.w<B.w;}38 行未改动int T=1;//cin>>T;while(T--)solve();return 0;}```##