HDU 1281 board game (two-part chart matching)

Source: Internet
Author: User

Problem Solving Ideas:

Enumerates all the squares on the board, and if the point is deleted, the maximum number of matches is reduced, then the point is the key point.

#include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <vector > #include <algorithm>using namespace std;const int maxn = + 10;int g[maxn][maxn];int vis[maxn];int MATCH[MAXN            ];int N, M, k;int path (int u) {for (int v=1;v<=m;v++) {if (G[u][v] &&!vis[v]) {            VIS[V] = 1;                if (match[v] = = 1 | | path (MATCH[V])) {Match[v] = u;            return 1; }}} return 0;}    int Maxmatch () {int res = 0;    memset (Match,-1, sizeof (match));        for (int i=1;i<=n;i++) {memset (Vis, 0, sizeof (VIS));    if (path (i)) res++; } return res;    int main () {int kcase = 1;        while (scanf ("%d%d%d", &n, &m, &k)!=eof) {int x, y;        memset (g, 0, sizeof (g));            for (int i=1;i<=k;i++) {scanf ("%d%d", &x, &y);        G[x][y] = 1;        } int ans = 0; int ACC= Maxmatch ();                for (int i=1;i<=n;i++) {for (int j=1;j<=m;j++) {if (G[i][j])                    {G[i][j] = 0;                    if (ACC > Maxmatch ()) ans++;                G[I][J] = 1;    }}} printf ("Board%d has%d important blanks for%d chessmen.\n", kcase++, ans, acc); } return 0;}


HDU 1281 board game (two-part chart matching)

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.