The Battle of Polygons (Bzoj 2927)

Source: Internet
Author: User

Description Polygon Battle is a two-player game. The game is performed on a convex polygon with n vertices, and the n-3 diagonal of the convex polygon divides the polygons into n-2 triangles, which intersect the vertices of the polygon in n-3 diagonal lines. One of the triangles is dyed black and the rest is white. The two sides take turns playing the game, when the turn of the side, he must follow the well-drawn diagonal, from the polygon cut a triangle. The side that cuts the black triangle wins. Note: If the segment that connects any two points in a polygon is completely contained in this polygon, it is called a convex polygon. Solve tasks:Please design a program: • Read in a description of a polygon. • Determine if the first party can win. • Outputs the result. The first line of input is an integer, 4 <= n <= 50000. Represents the number of vertices of a polygon, and the vertices of the polygon are labeled clockwise from 0 to N-1. The next line of N-2 describes the triangles that make up the polygon. Line i+1, 1 <= i <= n-2, has three space-delimited nonnegative integers a, B, C, which are the vertex numbers of the I-triangles. The first given triangle is a black one. The output unique row should contain a single word: TAK (Polish "yes"), indicating that the first party has a winning strategy, or NIE (Polish "no"), that the first party does not have a winning strategy. Sample Input6
0 1 2
2 4 3
4 2 0
0 5 4

Sample OutputTAK
/*The first game theory of his own hands ①: if the black triangle three side only one is diagonal, then the initiator will win.   ②: If n is an even number, the initiator will win.   The first one is very well understood, and the following is the second proof of my regression process: 1: Set the diagonal has T1 bar is the triangle, the T2 bar is not on the triangle.  2: If the initiator wins, then the last time to take a number, t1=1,t2=0, because if t2>0, the people of the back of the previous step must take M.  3: Count the second time, t1=2,t2=0, because if t1=1, then the hand is taken away. 4: (T1,T2) can be equivalent to (t1,t2%2) from this has been pushed to launch if the first t1+t2 is odd, the initiator will win, because T1+t2=n-3, if n is even, then the initiator will win. */#include<iostream>#include<cstdio>using namespacestd;intv[50010];intMain () {intn,a,b,c,t=0; scanf ("%d%d%d%d",&n,&a,&b,&c);  for(intI=1; i<=n-3; i++){        intX,Y,Z;SCANF ("%d%d%d",&x,&y,&z); V[X]++;v[y]++;v[z]++; }    if(!v[a]) t++; if(!v[b]) t++; if(!v[c]) t++; if(t==1|| n%2==0) printf ("TAK"); Elseprintf"NIE"); return 0;}

The Battle of Polygons (Bzoj 2927)

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.