QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114464#4589. White-Black Treeberarchegas#Compile Error//C++171.3kb2023-06-22 04:57:132023-06-22 04:57:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-22 04:57:16]
  • 评测
  • [2023-06-22 04:57:13]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const ll INF = 2e18;

vector<int> v[MAXN];
int cor[MAXN], dep[MAXN];

int calcDep(int node) {
    for (int x : v[node]) {
        dep[node] = max(dep[node], calcDep(x) + 1);
    }
    return dep[node];
}

int dfs(int node) {
    if (cor[node]) {
        // branco
        return dep[node] + 1;
    }
    else {
        // preto
        int ans = 0;
        for (int x : v[node]) {
            ans ^= dfs(x);
        }
        return ans;
    }
}

int ans[MAXN];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        v[p].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> cor[i];
    }
    calcDep(1);
    for (int i = 1; i <= n; i++) {
        if (cor[i]) ans[ dep[i] ] ^= 1;
    }

    for(int i = 0 ; i <= n ; i++)
    {
        if( ans[i] == 1 )
        {
            cout << "First" << endl;
            return;
        }
    }

    cout << "Second" << endl;

    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:63:13: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   63 |             return;
      |             ^~~~~~