Submission #778830

# Submission time Handle Problem Language Result Execution time Memory
778830 2023-07-10T18:48:46 Z benjaminkleyn Werewolf (IOI18_werewolf) C++17
0 / 100
187 ms 23028 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int par1[200000], par2[200000];
int find1(int u) { return par1[u] == u ? u : find1(par1[u]); }
int find2(int u) { return par2[u] == u ? u : find2(par2[u]); }
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R)
{
    int Q = S.size(), M = X.size();
    vector<int> A(Q, 0);

    for (int i = 0; i < N; i++)
        par1[i] = par2[i] = i;

    vector<vector<int>> g(N);
    for (int i = 0; i < M; i++)
    {
        g[X[i]].push_back(Y[i]);
        g[Y[i]].push_back(X[i]);
    }

    for (int u = 0; u < N; u++)
        for (int v : g[u])
            if (v < u)
                par1[find1(v)] = u;

    for (int u = N - 1; u >= 0; u--)
        for (int v : g[u])
            if (v > u)
                par2[find2(v)] = u;

    for (int i = 0; i < Q; i++)
    {
        int s = S[i], e = E[i];
        while (par1[e] != e&& par1[e] <= R[i])
            e = par1[e];
        while (par2[s] != s && par2[s] >= L[i])
            s = par2[s];
        A[i] = find1(e) == find1(s);
    }

    return A;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 23028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -