# P1640 [SCOI2010] continuous attack game

Source: Internet
Author: User

After doing this for a long time, I finally found a problem that can only be done with Hungary .
One-eyed dichotomy, but the modeling is very ingenious. The idea at first was to take two attributes on either side of the dichotomy, but found that it seemed difficult to handle one of the cases.
In fact this should put the attribute on the left, the number is placed on the right to match on OK.
Because the number must be continuous for the sake of, dinic here is powerless,,, helpless to learn a bit Hungary,,,

``#include <vector> #include <cstdio> #include <cstring> #include <cassert> #include <iostream  > #include <algorithm>using namespace std;const int maxn = 1e6 + 10;inline int read () {char ch = getchar (); int    x = 0;    while (!isdigit (ch)) ch = GetChar ();    while (IsDigit (ch)) x = x * + ch-' 0 ', ch = getchar (); return x;} int N; int MATCH[MAXN];        BOOL vis[maxn];vector<int> g[(int) 1e4 + 10];bool dfs (int u) {for (int i = 0; i < (int) g[u].size (); i++) {        int &v = G[u][i];            if (!vis[v]) {Vis[v] = true;        if (!match[v] | | DFS (MATCH[V)) return match[v] = u, true; }} return false;}    int main () {cin>>n;         for (int i = 1; I <= N; i++) G[read ()].push_back (i), G[read ()].push_back (i);    int ans = 0;        for (int i = 1; I <= (int) 1e4; i++) {memset (Vis, false, (N + 1) * sizeof (BOOL)); if (Dfs (i)) ++ans;    else break;    } printf ("%d\n", ans); return 0;}``

P1640 [SCOI2010] continuous attack game

Related Keywords:

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.