bool expr_handler::args_equal(const vvec &l, const vvec &r) { assert(l.size() == r.size()); int s = l.size(); for (int k = 0; k < s; ++k) { if (!l[k]->v_equal(r[k])) return false; } return true; }
void dump::dump_rels(vvec & vv) { for(vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value *v = *I; if (!v || !v->is_rel()) continue; sblog << "\n\t\t\t\t\t"; sblog << " rels: " << *v << " : "; dump_vec(v->mdef); sblog << " <= "; dump_vec(v->muse); } }
void ssa_rename::rename_src_vec(node *n, vvec &vv, bool src) { for(vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value* &v = *I; if (!v || v->is_readonly()) continue; if (v->is_rel()) { if (!v->rel->is_readonly()) v->rel = rename_use(n, v->rel); rename_src_vec(n, v->muse, true); } else if (src) v = rename_use(n, v); } }
void dump::dump_vec(const vvec & vv) { bool first = true; for(vvec::const_iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value *v = *I; if (!first) sblog << ", "; else first = false; if (v) { sblog << *v; } else { sblog << "__"; } } }
void ssa_rename::rename_dst_vec(node *n, vvec &vv, bool set_def) { for(vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value* &v = *I; if (!v) continue; if (v->is_rel()) { rename_dst_vec(n, v->mdef, false); } else { v = rename_def(n, v); if (set_def) v->def = n; } } }
void shader::fill_array_values(gpr_array *a, vvec &vv) { unsigned sz = a->array_size; vv.resize(sz); for (unsigned i = 0; i < a->array_size; ++i) { vv[i] = get_gpr_value(true, a->base_gpr.sel() + i, a->base_gpr.chan(), false); } }
void ra_checker::check_src_vec(node *n, unsigned id, vvec &vv, bool src) { for (vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value *v = *I; if (!v || !v->is_sgpr()) continue; if (v->is_rel()) { if (!v->rel) { sb_ostringstream o; o << "expected relative offset in " << *v; error(n, id, o.str()); return; } } else if (src) { check_value_gpr(n, id, v); } } }
void def_use::process_defs(node *n, vvec &vv, bool arr_def) { for (vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) { value *v = *I; if (!v) continue; if (arr_def) v->adef = n; else v->def = n; v->delete_uses(); if (v->is_rel()) { process_defs(n, v->mdef, true); } } }
void shader::add_pinned_gpr_values(vvec& vec, unsigned gpr, unsigned comp_mask, bool src) { unsigned chan = 0; while (comp_mask) { if (comp_mask & 1) { value *v = get_gpr_value(src, gpr, chan, false); v->flags |= (VLF_PIN_REG | VLF_PIN_CHAN); if (!v->is_rel()) { v->gpr = v->pin_gpr = v->select; v->fix(); } if (v->array && !v->array->gpr) { // if pinned value can be accessed with indirect addressing // pin the entire array to its original location v->array->gpr = v->array->base_gpr; } vec.push_back(v); } comp_mask >>= 1; ++chan; } }
int main(){ int i, u, v; cin>>n; rel.resize(n+2); for( i=1 ; i<n ; i++ ){ cin>>u>>v; rel[u].pb(v); rel[v].pb(u); } total_sum = 0; for( i=1 ; i<=n ; i++ ){ cin>>c[i]; total_sum += c[i]; vis[i] = 0; } visited = 0; ans = -1; par[1] = 1; int cc = dfs(1); if( ans != -1 ){ cout<<"YES\n"; cout<<ans<<"\n"; } else{ cout<<"NO\n"; } return 0; }