在其他地方过的了,结果 RE。
可以只给 hack
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int x,t[N];
char ch;
bool ans;
void make(int node){
int z=0;int num=0;char c;bool f=0;
while(cin>>c){
if(c=='-')f=1;
if(c>='0'&&c<='9')num=num*10+c-'0';
if(c=='('){t[node]=num*(f?-1:1);make(2*node+z++);}
if(c==')')return;
}
return;
}
bool dfs(int node,int su){
if(!t[2*node]&&!t[2*node+1]){return su+t[node]==x;}
return((t[2*node] ?dfs(2*node, su+t[node]):0)||
(t[2*node+1]?dfs(2*node+1,su+t[node]):0));
}
signed main(){
while(cin>>x>>ch){
memset(t,0,sizeof(t));
make(1);
ans=dfs(1,0);
if(ans)cout<<"yes\n";
else cout<<"no\n";
}
return 0;
}