Transmission Door
This is against the search is a thing ...
The first can be found in each row of the number of pieces is not less than the next line, and the situation can be represented by the number of pieces per line, then a m+1 number to represent the current situation, with Longlong, open map memory Search
And then the time complexity of the problem, Rqy said so
And then this fight search words ... Personal understanding is because to maximize the difference in score, so when a person plays chess, he scored the most, the other person scored the least
1 //Minamoto2#include <cstdio>3#include <iostream>4#include <map>5 #definell Long Long6 using namespacestd;7 #defineGetc () (p1==p2&& (p2= (p1=buf) +fread (Buf,1,1<<21,stdin), P1==P2)? eof:*p1++)8 Charbuf[1<< +],*p1=buf,*p2=buf;9template<classT>inlineBOOLCmax (T&a,ConstT&B) {returnA<b?a=b,1:0;}Tentemplate<classT>inlineBOOLCmin (T&a,ConstT&B) {returnA>b?a=b,1:0;} OneInlineintRead () { A #defineNum ch-' 0 ' - CharChBOOLflag=0;intRes; - while(!isdigit (ch=getc ())) the(ch=='-') && (flag=true); - for(Res=num;isdigit (Ch=getc ()); res=res*Ten+num); -(flag) && (res=-res); - #undefNum + returnRes; - } + Const intn= the,Base= A, inf=0x3f3f3f3f; AMap<ll,int> MP;inta[n][n],b[n][n],bl[n],n,m; at inline ll HSH () { -ll res=0; - for(intI=1; i<=n;++i) res=res*Base+Bl[i]; - returnRes; - } -InlinevoidUnzip (ll S) { in for(intI=n;i;--i) bl[i]=s%Base, s/=Base; - } toInlineintgetnxt () { + intres=0; - for(intI=1; i<=n;++i) res+=Bl[i]; the returnres&1; * } $ intDfs (ll S) {Panax Notoginseng if(Mp.find (S)!=mp.end ())returnMp[s]; - unzip (S); the intTYPE=GETNXT (), res=type?inf:-inf; + for(intI=1; i<=n;++i) A if(bl[i-1]>Bl[i]) { the++bl[i];ll h=HSH (); +Type?cmin (Res,dfs (h)-b[i][bl[i]): Cmax (Res,dfs (h) +A[i][bl[i]]); ---Bl[i]; $ } $ returnmp[s]=Res; - } - intMain () { the //freopen ("testdata.in", "R", stdin); -N=read (), M=read (), bl[0]=m;Wuyi for(intI=1; i<=n;++i) the for(intj=1; j<=m;++j) -a[i][j]=read (); Wu for(intI=1; i<=n;++i) - for(intj=1; j<=m;++j) Aboutb[i][j]=read (); $ for(intI=1; i<=n;++i) bl[i]=m; -ll Full=hsh (); mp[full]=0; -Dfs0); -printf"%d\n", mp[0]); A return 0; +}
P4363 [Nine provincial test 2018] a pair of wooden chess chess (against search + memory search)