QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245089#4583. Concerto de Pandemicwarner1129#RE 0ms0kbC++201.7kb2023-11-09 18:37:052023-11-09 18:37:05

Judging History

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

  • [2023-11-09 18:37:05]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-09 18:37:05]
  • 提交

answer

#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
template<class... T> void dbg(T... x) { char e{}; ((cerr << e << x, e = ' '), ...); }
template<class T> void org(T l, T r) { while (l != r) cerr << ' ' << *l++; cerr << '\n'; }
#define debug(x...) dbg(#x, '=', x, '\n')
#define olist(x...) dbg(#x, '='), org(x)
#else
#define debug(...) ((void)0)
#define olist(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second

using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;

constexpr int inf = 1e9;
constexpr int mod = 998244353;

template<class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template<class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }
template<class... T> int add(T... x) { int t{}; return (((t += x) %= mod), ...), t; }
template<class... T> int mul(T... x) { i64 t{1}; return (((t *= x) %= mod), ...), t; }

void solve() {
    int n;
    cin >> n;

    vector<int> A(n);
    vector G(n, vector<int>{});
    for (int i = 1; i < n; i++) {
        int f;
        cin >> f;
        f--;
        G[f].push_back(i);
    }

    for (int &x : A) cin >> x;

    vector<i64> siz(n, 1);
    function<i64(int)> dfs = [&](int u) -> int {
        i64 x = 0;
        for (int v : G[u]) {
            x ^= dfs(v);
            siz[u] *= siz[v] + 1;
        }
        if (A[u]) return siz[u];
        else return x;
    };

    if (dfs(0)) cout << "First\n";
    else cout << "Second\n";
    
}

signed main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    
    return 0;
}





Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

10 4 3 2
1 2
4 4
6 2
7 5
2 5 8

output:


result: