Acd, acd10

Source: Internet
Author: User

Acd, acd10

Q: N and P are playing games. N has n1 points, P has n2 points, and N has m undirected edges between P points. Place a stone on one of the points, N first move the stone, move it along the side once, the point before the stone moves and the side connected to the point are deleted, and then move the stone to P, whoever can't move will lose. Output the outcome for each initial position (1 ≤ n1; n2 ≤ 500, 0 ≤ m ≤ 50 000 ).

Question link: http://acdream.info/problem? Pid = 1, 1403

--> There are many types of maximum matching for a bipartite graph. However, there may be some vertices. No matter which of the largest matching schemes, they are all built points ..

Then, as long as the first hand moves along the matching edge from such a point, the latter hand can be forced to go nowhere .. (Why? First, move from A to B along the matching edge, and then from B to another C. Suppose C is not built, then, A matching edge A-B with the largest match can be changed to B-C, so A is not necessarily A built Point and does not meet our prerequisites .. Therefore, C must have been built, so first you can continue along the matching side, and finally destroy the opponent)

As a result, the dfs on both sides can find such a point twice ..

#include <cstdio>#include <cstring>const int MAXN = 1000 + 10;const int MAXM = 50000 + 10;struct EDGE{    int to;    int nxt;} edge[MAXM << 1];int n1, n2, m;int hed[MAXN], ecnt;int S[MAXN], T[MAXN];bool vis[MAXN];bool maxMatch[MAXN];void Init(){    ecnt = 0;    memset(hed, -1, sizeof(hed));}void AddEdge(int u, int v){    edge[ecnt].to = v;    edge[ecnt].nxt = hed[u];    hed[u] = ecnt++;}void Read(){    int u, v;    while (m--)    {        scanf("%d%d", &u, &v);        AddEdge(u, v + n1);        AddEdge(v + n1, u);    }    memset(maxMatch, 0, sizeof(maxMatch));}bool Match(int u){    for (int e = hed[u]; e != -1; e = edge[e].nxt)    {        int v = edge[e].to;        if (!vis[v])        {            vis[v] = true;            int temps = S[u];            int tempt = T[v];            S[u] = v;            T[v] = u;            if (tempt == -1 || Match(tempt)) return true;            T[v] = tempt;            S[u] = temps;        }    }    return false;}bool Judge(int u){    vis[u] = true;    if (S[u] == -1) return true;    u = S[u];    for (int e = hed[u]; e != -1; e = edge[e].nxt)    {        int v = edge[e].to;        if (!vis[v] && Judge(v)) return true;    }    return false;}void GetMaxMatchPointLeft(){    memset(S, -1, sizeof(S));    memset(T, -1, sizeof(T));    for (int i = 1; i <= n1; ++i)    {        memset(vis, 0, sizeof(vis));        if (Match(i))        {            maxMatch[i] = true;        }    }    for (int i = 1 + n1; i <= n2 + n1; ++i)    {        if (T[i] != -1)        {            memset(vis, 0, sizeof(vis));            if (Judge(T[i]))            {                maxMatch[T[i]] = false;            }        }    }}void GetMaxMatchPointRight(){    memset(S, -1, sizeof(S));    memset(T, -1, sizeof(T));    for (int i = 1 + n1; i <= n2 + n1; ++i)    {        memset(vis, 0, sizeof(vis));        if (Match(i))        {            maxMatch[i] = true;        }    }    for (int i = 1; i <= n1; ++i)    {        if (T[i] != -1)        {            memset(vis, 0, sizeof(vis));            if (Judge(T[i]))            {                maxMatch[T[i]] = false;            }        }    }}void Output(){    for (int i = 1; i <= n1; ++i)    {        maxMatch[i] ? putchar('N') : putchar('P');    }    puts("");    for (int i = 1 + n1; i <= n2 + n1; ++i)    {        maxMatch[i] ? putchar('N') : putchar('P');    }    puts("");}int main(){    while (scanf("%d%d%d", &n1, &n2, &m) == 3)    {        Init();        Read();        GetMaxMatchPointLeft();        GetMaxMatchPointRight();        Output();    }    return 0;}



What software does acdsee use?

ACDSee is one of the most popular image watching tools. it provides a good operation interface, simple and user-friendly operation mode, high-quality and fast graphic decoding mode, supports a wide range of graphic formats, powerful graphic file management functions, and so on.
ACDSee versions are not updated quickly, and the differences between interfaces between the new and old versions are not very obvious. However, each time a new version is released, some minor functions will be added to the program. ACDSee currently supports playing audio files in WAV format. It seems that the program will be developed for multimedia applications and playing platforms. currently, the latest version is ACDSee 2009 (English version) and the latest version is ACDSee 10.
ACDSee can be quickly enabled. Quick time and Adobe file browsing are added to most image formats. images can be zoomed in and out, and the window size can be adjusted in combination with the image size, full-Screen Image Browsing and support for GIF dynamic images. you can not only convert an image file to a BMP, JPG, or PCX file, but also set the image file to a desktop background with just one click. images can be viewed by means of slides and GIF animations. in addition, ACDSee provides a convenient electronic photo album. It has more than 10 sorting methods, including tree display of folders, my favorites, quick thumbnail viewing, drag-and-drop functions, and playback of WAV audio files, the archive manager can change the archive name in batches and edit the description of the program.
ACDSee also provides many image editing functions, including conversion of several image formats. You can use file descriptions to search for images, edit simple images, copy to a clipboard, rotate or trim images, set the desktop and input images from a digital camera. in addition, ACDSee supports multiple image printing options, allowing you to share images on the Internet and quickly and elastically transmit your digital images over the Internet.
ACDSee is the most widely used visualization tool. Most computer enthusiasts Use ACDSee to browse images. ACDSee features high support, it can open more than 20 image formats including ICO, PNG, and XBM, and can quickly display them with high quality, even animation image files that have become popular on the Internet in recent years can be viewed using ACDSee. It also features high speed. Compared with other image viewers, ACDSee can easily open image files. If you can make good use of some skills, it will bring you more convenience.

I hope my answers will help you.

What software does acdsee use?

ACDSee is one of the most popular image watching tools. it provides a good operation interface, simple and user-friendly operation mode, high-quality and fast graphic decoding mode, supports a wide range of graphic formats, powerful graphic file management functions, and so on.
ACDSee versions are not updated quickly, and the differences between interfaces between the new and old versions are not very obvious. However, each time a new version is released, some minor functions will be added to the program. ACDSee currently supports playing audio files in WAV format. It seems that the program will be developed for multimedia applications and playing platforms. currently, the latest version is ACDSee 2009 (English version) and the latest version is ACDSee 10.
ACDSee can be quickly enabled. Quick time and Adobe file browsing are added to most image formats. images can be zoomed in and out, and the window size can be adjusted in combination with the image size, full-Screen Image Browsing and support for GIF dynamic images. you can not only convert an image file to a BMP, JPG, or PCX file, but also set the image file to a desktop background with just one click. images can be viewed by means of slides and GIF animations. in addition, ACDSee provides a convenient electronic photo album. It has more than 10 sorting methods, including tree display of folders, my favorites, quick thumbnail viewing, drag-and-drop functions, and playback of WAV audio files, the archive manager can change the archive name in batches and edit the description of the program.
ACDSee also provides many image editing functions, including conversion of several image formats. You can use file descriptions to search for images, edit simple images, copy to a clipboard, rotate or trim images, set the desktop and input images from a digital camera. in addition, ACDSee supports multiple image printing options, allowing you to share images on the Internet and quickly and elastically transmit your digital images over the Internet.
ACDSee is the most widely used visualization tool. Most computer enthusiasts Use ACDSee to browse images. ACDSee features high support, it can open more than 20 image formats including ICO, PNG, and XBM, and can quickly display them with high quality, even animation image files that have become popular on the Internet in recent years can be viewed using ACDSee. It also features high speed. Compared with other image viewers, ACDSee can easily open image files. If you can make good use of some skills, it will bring you more convenience.

I hope my answers will help you.

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.