"POJ" "3537" crosses and crosses

Source: Internet
Author: User

Game theory

Equivalent to put X position, left and right 4 grid can no longer put X, who has nowhere to put lose.

n<=2000

The direct enumeration of subsequent States, the force of the SG function can be.

Example: 0000000->x. 0000/. x. 000/.. X.. 00/0..x. 0/00..x.

Memory Search write hung up ... or sequential DP-based = = (similar to S-nim, brute force for SG function)

1 Source Code2Problem:3537user:sdfzyhy3 memory:692k time:141ms4language:g++result:accepted5 6 Source Code7 8     //POJ 35379#include <cmath>Ten#include <queue> One#include <vector> A#include <string> -#include <cstdio> -#include <cstring> the#include <cstdlib> -#include <iostream> -#include <algorithm> -     #defineRep (i,n) for (int i=0;i<n;++i) +     #defineF (i,j,n) for (int i=j;i<=n;++i) -     #defineD (i,j,n) for (int i=j;i>=n;--i) +     using namespacestd; A  at     intGetint () { -         intR=0, c=1;CharCh=GetChar (); -          for(;! IsDigit (CH); Ch=getchar ())if(ch=='-') c=-1; -          for(; isdigit (ch); Ch=getchar ()) r=r*Ten+ch-'0'; -         returnr*C; -     } in     Const intn= ., inf=~0u>>2; -     Const Doubleeps=1e-9; to     /******************template***********************/ +     intDp[n],n; -     BOOLVis[n],mark[n]; the  *     intMain () { $n=getint ();Panax Notoginsengdp[0]=0; dp[1]=dp[2]=dp[3]=1; -F (I,4, N) { thememset (Mark,0,sizeofmark); +mark[dp[i-3]]=mark[dp[i-4]]=mark[dp[i-5]]=1; A              for(intj=1; j<=i-5-j;j++) themark[dp[j]^dp[i-5-j]]=1; +F (J,0, N)if(!mark[j]) {dp[i]=j; Break;} -         } $printf"%d\n", Dp[n]?1:2); $         return 0; -}
View Code

"POJ" "3537" crosses and crosses

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.