HDU 3118 arbiter (enumeration)

Source: Internet
Author: User

Who would have missed this question during the competition, and then would have regretted it?

First, the question is very simple, that is, let you remove the minimum number of edges in the graph and make the distance between any two points in the graph an even number.

That is, No Odd Circle exists in the graph.

This is easy to think of a two-part graph. Considering that the data size is small, you can enumerate it now. How can we enumerate it and divide the entire graph enumeration into two parts?

Then remove the edge in the same set. Here, the enumeration uses binary enumeration. 0 represents a set, 1 represents a set, and then traverses all

If the two ends of an edge are in a set, remove them directly and select the smallest

Here we get a lesson & the result of bitwise operation is an integer. to judge the equality, we need to forcibly convert the bool type to obtain bool equality.

(Bool (1 <po [J]. X) & I) = (bool (1 <po [J]. Y) & I ))

 # include 
  
    # include 
   
     # include 
    
      using namespace STD; # define maxn 305int n, m; struct point {int X; int y;} po [maxn]; int main () {int t; int I, j, ANS, re_ans; scanf ("% d", & T); While (t --) {scanf ("% d", & N, & M ); for (I = 0; I 
     
       re_ans) ans = re_ans;} printf ("% d \ n", ANS);} return 0 ;} 
     
    
   
  

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.