tyvj3632| Superhero hero

Source: Internet
Author: User

Description
now the TV station has a kind of program called superhero, the approximate process is each player to the stage to answer the host several questions, and then according to answer the question how much to obtain a different number of prizes or bonuses. Moderator questions prepared a number of topics, only when the player correctly answer a question, can enter the next question, or be eliminated. In order to increase the interest of the program and to reduce the difficulty, the host always provide players with several "tricks", such as to help the audience, or remove a number of wrong answers (choice) and so on. Here, let's change the rules a little bit. Assuming that the host has a total of M-questions, the contestants have n different "tricks". The moderator stipulates that each problem can be selected from two "tricks", and each "Ace" can only be used once. We also assume that a problem with the use of it allows the ACE, it will be able to correctly answer, smoothly into the next question. Now I came to the show, but I was too stupid, so that a problem will not do, each problem had to use the "Ace" to pass. If I knew in advance which two "tricks" can be used for each question, then can you tell me how to choose the maximum number of questions?
Input
the input file is a line of two positive integers n and m (0 < n <1001,0 < M < 1001) indicating a total of n "tricks", numbered Wei 0~n-1, a total of M brother problem.
The following M-line, two numbers per line, indicates the number of "Ace" that can be used for question M.
Note that each number of "Ace" can only be used once, the same problem of two "tricks" may be the same.
Output
the maximum number of questions the first behavior can pass p
Sample Input
5 6
3 2
2 0
0 3
0 4
3 2
3 2
Sample Output
4

Analysis: Binary graph matching ... Rokua bully me, do not let my sap through, who is afraid of who ah Lao I will know the felling of Hungary? The result in Rokua and BZ all WA, TMD in tyvj past what is the ghost Ah?

#include <iostream>#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespacestd;intmap[1001][1001],lk[1001],ans[1001];BOOLuse[1001];intn,m;BOOLFindintx) {     for(intI=0; i<n; i++)    {        if(!use[i] &&Map[x][i]) {Use[i]=1; if(!lk[i] | |find (Lk[i])) {Lk[i]=x; ANS[X]=i; return 1; }        }    }    return 0;}intMain () {CIN>> N >>m;  for(intI=1; i<=m; i++)    {        intx, y; CIN>> x >>y; MAP[I][X]=map[i][y]=1; } memset (ans,-1,sizeof(ans));  for(intI=1; i<=m; i++) {memset (use,0,sizeof(use)); if(Find (i)) ans[0]++; Else  Break; } ans[0]++; cout<< ans[0]; return 0;}

tyvj3632| Superhero hero

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.