POJ2599 A funny game (image game), poj2599funny

Source: Internet
Author: User

POJ2599 A funny game (image game), poj2599funny

Question link: Portal

Question:

Given a chart, two people start from the starting point and fly in turn. When they leave this point, this point

You can't use it anymore. If it's your turn, you will lose if anyone can't fly.

It is difficult to find a failure. When a person is in the position s, there is no point that can be connected to this point.

It will be defeated. Then the data is small, and you can directly perform a brute-force search.

The Code is as follows:

# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # include <set> # include <map> # include <queue> # define PB push_back # define MP make_pair # define REP (I, n) for (int I = 0; I <(n); ++ I) # define FOR (I, l, h) for (int I = (l ); I <= (h); ++ I) # define DWN (I, h, l) for (int I = (h); I> = (l); -- I) # define IFOR (I, h, l, v) for (int I = (h); I <= (l); I + = (v )) # define CLR (vis) memset (vis, 0, sizeof (vis) # define MST (vis, pos) memset (vis, pos, sizeof (vis) # define MAX3 (a, B, c) max (a, max (B, c )) # define MAX4 (a, B, c, d) max (a, B), max (c, d) # define MIN3 (a, B, c) min (a, min (B, c) # define MIN4 (a, B, c, d) min (a, B), min (c, d )) # define PI acos (-1.0) # define INF 1000000000 # define LINF extends limit 0000000000ll # define eps 1e-8 # define LL long longusing namespace std; const int maxn = 1001; int mp [maxn] [maxn]; bool vis [maxn]; int ans, n, s; B Ool dfs (int id) {FOR (I, 1, n) {if (mp [id] [I] &! Vis [I]) {// The Order of traversing the graph ensures that the answer is Min vis [id] = 1; if (! Dfs (I) {vis [id] = 0; ans = I; return true ;}} vis [id] = 0 ;}return false ;} int main () {while (~ Scanf ("% d", & n, & s) {CLR (mp); REP (I, n-1) {int u, v; scanf ("% d", & u, & v); mp [u] [v] = 1; mp [v] [u] = 1 ;} CLR (vis); if (dfs (s) printf ("First player wins flying to airport % d \ n", ans ); else puts ("First player loses");} 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.