The game of "BZOJ3880" to have the limit of the ring of the Jin Chen I'm the one who made the quiz!

Source: Internet
Author: User

Reprint Please specify the source Thank you: blog.csdn.net/vmurder/article/details/42968425

Ah that what 94.net this is a puzzle you if reproduced do not delete the source of thank you ...

I'll take care of it. Blog. Csdn NET| Vmurder| Article| Details| 42968425

。 Is.

| Yes/

Do an experiment: see if its reprint mechanism will remove the code.

#include <cstdio>using namespace Std;int main () {puts ("blog.csdn.net/vmurder/article/details/42968425");}



Well, it's an original question.

Then the following is what I wrote at that time.

I thought I could spend some time in bzoj to think about this problem.

But it seems I think more ...


{

This problem is obviously a game problem, and then because the ring broke a point, so it is advisable to deal with it as a chain. I have a character for the data: any two edges do not intersect. That's a lot to do.

First of all, we think, starting from the starting point, then because every point, before the point has gone through, so now can not go back through the side, then that is, when the total number of points (do not forget to cut the breakpoint) is odd, directly from 1, you can guarantee victory.

So what if the total number of points is even? Say, we go straight from the second point on the line, really OK? This time there will be a problem, is to go forward, there may be some point can go back to 1, so the initiator lost, so it is not possible to think so simple.

This problem limits the side not "cross", so the chain must be divided into several (can only 1) independent of the interval, and we start from the beginning of each interval, it is impossible to return to the previous node.

And if we start from the middle of a range, then we can go back one step at the most, then we need to move forward, and the first node of the node is a winning node.

This time we are discussing: (the total number of nodes is even, otherwise directly out of the solution)

---------------------------------------------------

First, from the Singularity Point, the initiator can choose to backtrack in the even point, if this even point can be returned to even point, that is wins. And we also need to make sure that the other side can't get back to my point at odd points.

Second, from the occasional point, the initiator can choose to backtrack in the singularity, if this singularity can return to the singularity, that is, win. And we also need to ensure that the other side cannot return to the singularity.

--------------------------------------------------

Note that the above two cases, starting from the singularity must backtrack, and even point is not. So we can judge an end node for an interval:

If the end node is even, and cannot go back to the singularity, then win.

If the end of the node is odd, then we can not start at the end of the node, or the other side only need to move forward, we lose, and can not be reversed.

After the end of the node, we can find that if we can backtrack on a node and win, then from the Start node to this section of the node, the other side is not able to reverse the opportunity (odd point back/even point back odd), so we may wish to push the start node infinitely right, pushed to the back of the back node.

Then for each interval, we only need to enumerate the backtracking nodes, and check if the previous node can be reversed, it can be solved.

Obviously this sweep again, found that all the nodes are going to lose, then this game is lost, so it can only output "dirty".

Details: We have recorded whether each point can be traced back to odd/even points, but it is possible to backtrack, check has been blocked? No way.

Because the singularity needs to go back to the odd, and we start with the previous point (even), and even the same.

Say this problem can be memory of deep search water? If possible, then the idea should be only to judge a node if it is a section of the beginning of the node, then it can only go forward, can not turn back, it is an end node, and then can be memory of the deduction.

But in this problem, a node is not out of the side can go, and state compression, but also live in the dream, random yy a bit, feel not so water.

I think again, found that the memory of the search words you do not know those points can go, which points do not, such as even ring rings, the outside of the even ring you can directly according to the parity of the victory and defeat, inside the ring it? 233. No card required! because it can't be searched by itself! To remember, you can only enumerate the starting point, (this seems still not possible), and then search, even if feasible, is n^2, obviously tle ...

}

Code:

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 1001000using namespace Std;int n,m,vv[n],cnt;bool jd[n][2];void build_chain () {int a,b,c; scanf ("%d%d%d", &n, &AMP;M,&AMP;C); for (int i=1;i<n;i++) Vv[i]=i;while (m--) {scanf ("%d%d", &a,&b); if (a==b| | a==c| | B==c) continue;a= (a+n-c)%n,b= (b+n-c)%n;if (a<b) {Vv[a]=max (vv[a],b); jd[b][a&1]=1;} Else{vv[b]=max (vv[b],a); jd[a][b&1]=1;}} n--;} int L[n],r[n];bool build_district () {for (int i=1;i<=n;i++) {cnt++;if (vv[i]==i) return 1;l[cnt]=i;r[cnt]=i=vv[i];} return 0;} BOOL Check (int f) {if ((r[f]&1) ==0&&jd[r[f]][1]==0) return 1;for (int i=l[f]+1;i<=r[f];i++) {if (i&1 ) (&&jd[i][1]) if (jd[i-1][1]==false) return 1;if ((i%2==0) &&jd[i][0]) if (jd[i-1][0]==false) return 1;} return 0;} int main () {build_chain (); if (!n) {puts ("Galaxy"); return 0;} if ((n&1) | | | Build_district () ==1) {puts ("Dawn"); return 0;} for (int i=1;i<=cnt;i++) {if (check (i)) {puts ("Dawn"); return 0;}} Puts"Galaxy"); return 0;} 


The game of "BZOJ3880" to have the limit of the ring of the Jin Chen I'm the one who made the quiz!

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.