Topic Link: Click to open the link
Test instructions
Given a full graph of n points, the following gives the edge of the M-bar edge not 0
The following M-line gives the edge and edge rights.
The other Bingban are 0.
Select a vertex to export the sub-graph, where each point weight is the minimum edge of the connection for that point.
Find a sub-graph like this to make point right and maximum, output point right and.
Ideas:
Because it is a complete graph, the points we choose to make up the graph must not contain a weighted 0 edge. Because if you include an edge with a weight of 0, you can delete these two points without reducing the answer.
So the edges of the graph we select must contain only the M-bar, and a regiment of this M-edge.
To determine the maximum number of points in this regiment, set the maximum n points, then the group's Edge is N (n-1)/2, and the input is only 100 edges
i.e. n (n-1)/2 <= and N <=14
So we'll just have to search these 14 points.
#include <bits/stdc++.h>template <class t>inline BOOL Rd (T &ret) {char c; int sgn; if (C=getchar (), c==eof) return 0; while (c!= '-' && (c< ' 0 ' | | C> ' 9 ')) C=getchar (); sgn= (c== '-')? -1:1; ret= (c== '-')? 0: (c ' 0 '); while (C=getchar (), c>= ' 0 ' &&c<= ' 9 ') ret=ret*10+ (c ' 0 '); RET*=SGN; return 1;} Template <class t>inline void pt (T x) {if (x <0) {Putchar ('-'); x =-X; } if (X>9) pt (X/10); Putchar (x%10+ ' 0 ');} Using namespace Std;typedef long long ll;const int n = 105;int ans, mp[n][n];int a[20], d[20], n;void work (int n) {int c = 0, CC; for (int i = 1; I <= n; i++) {cc = 1e8; for (int j = 1; J <= N; j + +) if (i!=j) cc = MIN (cc, mp[a[i]][a[j]]); c + = cc; } ans = max (ans, c);} void Dfs (int u) {if (U >= 3) work (U-1); for (int i = a[u-1]+1; I <= n; i++) {bool OK = true; for (int j = 1; J < u && OK; j + +) if (mp[i][a[j]] = = 0) ok = false; A[u] = i; if (OK) DFS (u+1); }}int Main () {int u, V, D, M; while (cin>>n>>m) {ans = 0; Memset (MP, 0, sizeof MP); while (m--) {rd (U); Rd (v); Rd (d); MP[U][V] = mp[v][u] = D; ans = max (ans, d<<1); } dfs (1); cout<<ans<<endl; } return 0;}
Rabbit PartyTime limit:5 sec, Memory limit:65536 KBRabbit Party
A rabbit Taro decided to hold a party and invite some friends as guests. He hasnRabbit Friends, andmPairs of rabbits is also friends with all other. Friendliness of each pair are expressed with a positive integer. If The Rabbits is isn't friends, their friendliness is assumed-be 0.
When a rabbit was invited to the party, his satisfaction score was defined as the minimal friendliness with any other guests . The satisfaction of the party itself are defined as the sum of satisfaction score for all the guests.
To maximize satisfaction scores for the party, who should Taro invite? Write a program to calculate the maximal possible satisfaction score for the party.
Input
The first line of the input contains the integers,nandm(1≤n≤100,0≤m≤100). The rabbits is numbered from1Ton.
Each of the followingmLines has three integers,u,vandf.uandv(1≤u,v≤n,u≠v,1≤f≤1,000,000) stands for the Rabbits ' number, andfstands for their friendliness.
Assume that the friendliness of a pair of rabbits'll be given at the very most once.
Output
Output the maximal possible satisfaction score of the party in a line.
Sample Input 1
3 31 2 32 3 13 1 2
Output for the Sample Input 1
6
Sample Input 2
2 11 2 5
Output for the Sample Input 2
10
Sample Input 3
1 0
Output for the Sample Input 3
0
Sample Input 4
4 51 2 41 3 32 3 72 4 53 4 6
Output for the Sample Input 4
16
Aizu 2306 Rabbit Party burst search vertex export sub-map