hiho week 217 register

Ended

Participants:160

Verdict:Wrong Answer
Score:50 / 100
Submitted:2018-08-27 15:53:59

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
const string a = "AND";
const string b = "OR";
const string t = "TRUE";
const string f = "FALSE";
struct node{
    int id;
    string r;
    bool val;
};
vector<node>tree[1000];
const int inf = 0x3f3f3f3f;
int dp[1000],ans,maxn = 0;
void dfs(int now)
{
    int nxt;
    for(int i = 0;i < tree[now].size();++i){
        nxt = tree[now][i].id;
        if(tree[nxt].size() && (tree[nxt][(nxt & 1)].r == t || tree[nxt][(nxt & 1)].r == f)) tree[now][i].val = tree[nxt][i].val;
        dfs(nxt);
        if(tree[nxt].size() && (tree[nxt][i].r == t || tree[nxt][i].r == f)){
            dp[tree[nxt][i].id] = 0;
        }
        else{
            if(tree[nxt].size() && (tree[nxt][0].val != tree[nxt][1].val))
                dp[tree[now][i].id] = min(dp[tree[nxt][0].id],dp[tree[nxt][1].id]) + 1;
            else if(tree[nxt].size())
                dp[tree[nxt][0].id] = dp[tree[nxt][1].id] = 0;
        }
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX