In the FOJ 2141 random method, the number of edges is at least half of the homogeneous subgraph of the source image and the subgraph is a bipartite graph.

Source: Internet
Author: User

 

Question:

N vertices and m undirected Edges

Returns an homogeneous subgraph that contains at least m edges and is a bipartite graph.

Output X point set and Y point set of the Bipartite Graph

 

Ideas:

Non-Positive Solution

We can randomly generate a group of solutions first, and then determine whether the group of solutions is feasible (the estimated feasible solution space is large)


# Include

 
  
# Include

  
   
Using namespace std; # define N 105 bool s [N]; int n, m; int Stack [N], top, nowlen; struct node {int u, v ;} edge [10096]; int edgenum; void put (bool hehe) {top = 0; for (int I = 1; I <= n; I ++) if (s [I] = hehe) Stack [top ++] = I; printf (% d, top); if (top) sort (Stack, Stack + top ); while (top --) printf (% d, Stack [top]); printf () ;}int main () {int T, I; scanf (% d, & T ); while (T --) {edgenum = nowlen = 0; scanf (% d, & n, & m); for (I = 0; I <m; I ++) {scanf (% d, & edge [edgenum]. u, & edge [edgenum]. v); edgenum ++;} while (nowlen

   

  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.