这不是机惨
我就是想把2000行的垃圾代码放一下装个逼
Code For 《Betrayal》 :
#include<cstdio> #include<iostream> #include<cstring> using namespace std; int lev[6][11],ini[6],n; double res[15][105]; //1:M 2:Sp 3:Sa 4:K struct thing { int sk; int op; /* 1 1:直接+ 2 1:直接加判定 3 1:判定直接加 4 1:判定加判定 */ int num; int consk,conp,conum; /* 1: > 2: >= 3: < 4: <= */ }t[105]; double ans[6][11],dead; int abss(int x) { return x>0?x:-x; } void pre() { res[1][0]=0.333333333333333; res[1][1]=0.333333333333333; res[1][2]=0.333333333333333; res[2][0]=0.111111111111111; res[2][1]=0.222222222222222; res[2][2]=0.333333333333333; res[2][3]=0.222222222222222; res[2][4]=0.111111111111111; res[3][0]=0.037037037037037; res[3][1]=0.111111111111111; res[3][2]=0.222222222222222; res[3][3]=0.259259259259259; res[3][4]=0.222222222222222; res[3][5]=0.111111111111111; res[3][6]=0.037037037037037; res[4][0]=0.012345679012346; res[4][1]=0.049382716049383; res[4][2]=0.123456790123457; res[4][3]=0.197530864197531; res[4][4]=0.234567901234568; res[4][5]=0.197530864197531; res[4][6]=0.123456790123457; res[4][7]=0.049382716049383; res[4][8]=0.012345679012346; res[5][0]=0.004115226337449; res[5][1]=0.020576131687243; res[5][2]=0.061728395061728; res[5][3]=0.123456790123457; res[5][4]=0.185185185185185; res[5][5]=0.209876543209877; res[5][6]=0.185185185185185; res[5][7]=0.123456790123457; res[5][8]=0.061728395061728; res[5][9]=0.020576131687243; res[5][10]=0.004115226337449; res[6][0]=0.001371742112483; res[6][1]=0.008230452674897; res[6][2]=0.028806584362140; res[6][3]=0.068587105624143; res[6][4]=0.123456790123457; res[6][5]=0.172839506172840; res[6][6]=0.193415637860083; res[6][7]=0.172839506172840; res[6][8]=0.123456790123457; res[6][9]=0.068587105624143; res[6][10]=0.028806584362140; res[6][11]=0.008230452674897; res[6][12]=0.001371742112483; res[7][0]=0.000457247370828; res[7][1]=0.003200731595793; res[7][2]=0.012802926383173; res[7][3]=0.035208047553727; res[7][4]=0.073616826703246; res[7][5]=0.121627800640146; res[7][6]=0.163237311385458; res[7][7]=0.179698216735253; res[7][8]=0.163237311385458; res[7][9]=0.121627800640146; res[7][10]=0.073616826703246; res[7][11]=0.035208047553727; res[7][12]=0.012802926383173; res[7][13]=0.003200731595793; res[7][14]=0.000457247370828; res[8][0]=0.000152415790276; res[8][1]=0.001219326322207; res[8][2]=0.005486968449931; res[8][3]=0.017070568510898; res[8][4]=0.040542600213382; res[8][5]=0.076817558299041; res[8][6]=0.119493979576286; res[8][7]=0.154854442920286; res[8][8]=0.168724279835390; res[8][9]=0.154854442920286; res[8][10]=0.119493979576286; res[8][11]=0.076817558299041; res[8][12]=0.040542600213382; res[8][13]=0.017070568510898; res[8][14]=0.005486968449931; res[8][15]=0.001219326322207; res[8][16]=0.000152415790276; } int judge(char c1,char c2) { if(c1=='M')return 1; else if(c1=='S'&&c2=='p')return 2; else if(c1=='S'&&c2=='a')return 3; else if(c1=='K')return 4; return -1; } int isop(char s) { if(s=='+')return 1; else if(s=='-')return -1; return 0; } double dp[103][12][12][12][12]; #define Poss dp[x][n1][n2][n3][n4] void work(int x,int n1,int n2,int n3,int n4) { if(t[x].op==1) { if(t[x].sk==1) { int nxt=min(n1+t[x].num,8); if(nxt<=0)dead+=Poss; else dp[x+1][nxt][n2][n3][n4]+=Poss; } else if(t[x].sk==2) { int nxt=min(n2+t[x].num,8); if(nxt<=0)dead+=Poss; else dp[x+1][n1][nxt][n3][n4]+=Poss; } else if(t[x].sk==3) { int nxt=min(n3+t[x].num,8); if(nxt<=0)dead+=Poss; else dp[x+1][n1][n2][nxt][n4]+=Poss; } else if(t[x].sk==4) { int nxt=min(n4+t[x].num,8); if(nxt<=0)dead+=Poss; else dp[x+1][n1][n2][n3][nxt]+=Poss; } } else if(t[x].op==2) { if(t[x].sk==1) { for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*res[abss(t[x].num)][i]; } } else if(t[x].sk==2) { for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*res[abss(t[x].num)][i]; } } else if(t[x].sk==3) { for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*res[abss(t[x].num)][i]; } } else if(t[x].sk==4) { for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*res[abss(t[x].num)][i]; } } } else if(t[x].op==3) { if(t[x].sk==1) { if(t[x].conp==1) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==2) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==3) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==4) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n1+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==2) { if(t[x].conp==1) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==2) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==3) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==4) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n2+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==3) { if(t[x].conp==1) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==2) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==3) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==4) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n3+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==4) { if(t[x].conp==1) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==2) { if(t[x].consk==1) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==3) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].conp==4) { if(t[x].consk==1) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==2) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==3) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].consk==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; int nxt=min(8,n4+t[x].num); if(nxt<=0)dead+=Poss*ok; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok; dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } } else if(t[x].op==4) { if(t[x].sk==1) { if(t[x].consk==1) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==2) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==3) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==4) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n1+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][nxt][n2][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==2) { if(t[x].consk==1) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==2) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==3) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==4) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n2+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][nxt][n3][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==3) { if(t[x].consk==1) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==2) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==3) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==4) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n3+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][nxt][n4]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } else if(t[x].sk==4) { if(t[x].consk==1) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[1][n1];i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[1][n1]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==2) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[2][n2];i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[2][n2]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==3) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[3][n3];i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[3][n3]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } else if(t[x].consk==4) { if(t[x].conp==1) { double ok=0; for(int i=t[x].conum+1;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==2) { double ok=0; for(int i=t[x].conum;i<=2*lev[4][n4];i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==3) { double ok=0; for(int i=0;i<=t[x].conum-1;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } else if(t[x].conp==4) { double ok=0; for(int i=0;i<=t[x].conum;i++) ok+=res[lev[4][n4]][i]; for(int i=0;i<=abss(t[x].num)*2;i++) { int f=t[x].num>0?1:-1; int nxt=min(n4+f*i,8); if(nxt<=0)dead+=Poss*ok*res[abss(t[x].num)][i]; else dp[x+1][n1][n2][n3][nxt]+=Poss*ok*res[abss(t[x].num)][i]; } dp[x+1][n1][n2][n3][n4]+=Poss*(1.0-ok); } } } } } int main() { char str[105];pre(); for(int i=1;i<=4;i++) { scanf("%s",str+1); int len=strlen(str+1); for(int j=1;j<=len;j++) lev[i][j]=str[j]-'0'; scanf("%d",&ini[i]); } scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%s",str+1); t[i].sk=judge(str[1],str[2]); scanf("%s",str+1); if(isop(str[1])) { int len=strlen(str+1); if(str[len]!='?')t[i].op=1; else t[i].op=2; int x=0,j=2; while(isdigit(str[j]))x=x*10+str[j]-'0',j++; t[i].num=isop(str[1])*x; } else { int len=strlen(str+1); if(len==1) { if(str[1]=='>')t[i].conp=1; else if(str[1]=='<')t[i].conp=3; } else { if(str[1]=='>')t[i].conp=2; else if(str[1]=='<')t[i].conp=4; } scanf("%s",str+1); int x=0,j=1; while(isdigit(str[j]))x=x*10+str[j]-'0',j++; t[i].conum=x; scanf("%s",str+1); t[i].consk=judge(str[1],str[2]);swap(t[i].consk,t[i].sk); scanf("%s",str+1); len=strlen(str+1); if(str[len]=='?')t[i].op=4; else t[i].op=3; x=0,j=2; while(isdigit(str[j]))x=x*10+str[j]-'0',j++; t[i].num=isop(str[1])*x; } } /*for(int i=1;i<=n;i++) cout<<i<<' '<<t[i].op<<' '<<t[i].sk<<' '<<t[i].num<<' '<<t[i].consk<<' '<<' '<<t[i].conp<<' '<<t[i].conum<<endl;*/ dp[1][ini[1]][ini[2]][ini[3]][ini[4]]=1.0; for(int x=0;x<=n;x++) for(int now1=1;now1<=8;now1++) for(int now2=1;now2<=8;now2++) for(int now3=1;now3<=8;now3++) for(int now4=1;now4<=8;now4++) work(x,now1,now2,now3,now4); for(int now1=1;now1<=8;now1++) for(int now2=1;now2<=8;now2++) for(int now3=1;now3<=8;now3++) for(int now4=1;now4<=8;now4++) { ans[1][lev[1][now1]]+=dp[n+1][now1][now2][now3][now4]; ans[2][lev[2][now2]]+=dp[n+1][now1][now2][now3][now4]; ans[3][lev[3][now3]]+=dp[n+1][now1][now2][now3][now4]; ans[4][lev[4][now4]]+=dp[n+1][now1][now2][now3][now4]; } printf("%.2lf ",dead*100); for(int i=1;i<=4;i++) { for(int j=1;j<=8;j++) printf("%.2lf ",ans[i][j]*100); putchar(' '); } return 0; }