Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
非常 奇怪```有两个变量不能动,一动就WA或者RE 搞不懂,.什么问题?#include <iostream> #define MAX_LINE 18 #define MAX_T 9 #define MAX_SN 0X40000 #define MAXN 1<<18 using namespace std; int exp[MAX_LINE + 1] = {0, 0X1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000}; int f[MAX_SN + 5], mark[10][10],n; /************** 就是下面caseN 和 stepN ,为什么呢,赐教************/ int caseN, stepN; int edge[19][4] = {{0,0,0,0},{2,3,0,0},{1,3,0,0},{1,2,5,6},{5,8,0,0},{3,6,4,8},{3,5,7,9}, {6,9,0,0},{4,5,11,12},{6,7,13,14},{11,16,0,0},{10,16,8,12},{8,11,13,17}, {12,17,9,14},{9,13,15,18},{14,18,0,0},{10,11,0,0},{12,13,0,0},{14,15,0,0}}; void init() { mark[1][2] = 1; mark[1][3] = 2; mark[2][3] = 3; mark[2][4] = 4; mark[2][5] = 5; mark[3][5] = 6; mark[3][6] = 7; mark[4][5] = 8; mark[5][6] = 9; mark[4][7] = 10; mark[4][8] = 11; mark[5][8] = 12; mark[5][9] = 13; mark[6][9] = 14; mark[6][10] = 15; mark[7][8] = 16; mark[8][9] = 17; mark[9][10] = 18; } int takeStep(int state,int nub){ bool good=true; int v,num=0; for(int i=0;i<2;i++){ v=exp[edge[nub][i]]; if((v&state)==0){ good=false; break; } } if(good)num++; good=true; for(int i=2;i<4;i++){ v=exp[edge[nub][i]]; if((state&v)==0){ good=false; break; } } if(good)num++; return num; } int dpSolve(int state){ if(f[state]!=INT_MIN)return f[state]; int fag=1,tag,v,num,ans=INT_MIN; for(int i=1;i<19;i++){ if((state&exp[i])==0){ num=takeStep(state,i); if(num>0)tag=num+dpSolve(state|exp[i]); else tag=num-dpSolve(state|exp[i]); ans=max(ans,tag); } } return f[state]=ans; } int main(){ init(); int caseN,from,to,state,fag,tage,nb,tim=0; scanf("%d",&caseN); while(caseN--){ scanf("%d",&n); for(int i=0;i<=MAX_SN;i++)f[i]=INT_MIN; f[0X3ffff] = 0; state=tage=0; fag=1; int num=0; for(int i=0;i<n;i++){ scanf("%d%d",&from,&to); if(from>to)swap(from,to); nb=mark[from][to]; num=takeStep(state,nb); state|=exp[nb]; if(num>0){ tage+=fag*num; } else fag*=-1; } tage+=fag*dpSolve(state); printf(tage>0?"Game %d: A wins.\n":"Game %d: B wins.\n",++tim); } system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator