爆搜
1 #include2 #define maxn 20 3 #define LL long long 4 #define INF 0x7fffffff 5 using namespace std; 6 int seg[maxn],n,r1,r2; 7 char op[maxn],o[maxn]; 8 LL cal(LL x,LL y,char opt){ 9 if(opt=='*') return x*y; 10 else if(opt=='+') return x+y; 11 else if(opt=='-') return x-y; 12 } 13 LL dfs1(LL *a,int len1,char *s,int len2,int p){ 14 LL xx; 15 if(len1==3){ 16 if(p==1){ 17 xx=max(cal(cal(a[1],a[2],s[1]),a[3],s[2]),cal(a[1],cal(a[2],a[3],s[2]),s[1])); 18 return xx; 19 } 20 else{ 21 xx=min(cal(cal(a[1],a[2],s[1]),a[3],s[2]),cal(a[1],cal(a[2],a[3],s[2]),s[1])); 22 return xx; 23 } 24 } 25 if(len1==2){ 26 return cal(a[1],a[2],s[1]); 27 } 28 if(len1==1){ 29 return a[1]; 30 } 31 LL tem[maxn],t; 32 char o[maxn]; 33 if(p==1) t=-INF; 34 else t=INF; 35 for(int i=1;i >T; 54 int flag=0,tot=0; 55 LL tem[maxn]; 56 LL res,l1,l2,ans; 57 while(T--){ 58 cin>>n; 59 n++; 60 r1=-INF,r2=INF; 61 for(int i=1;i<=n-1;i++){ 62 scanf("%d",&seg[i]); 63 cin>>op[i]; 64 } 65 cin>>seg[n]; 66 for(int i=1;i res){ 88 r2=res; 89 l2=i; 90 } 91 } 92 cout<<"Player 2 "<<"("< < < <<") leads to "< < -r2) flag=1; 94 else if(r1<-r2) flag=-1; 95 else flag=0; 96 if(flag==1) cout<<"Player 1 wins"<