Submission #861129

#TimeUsernameProblemLanguageResultExecution timeMemory
861129TahirAliyevWerewolf (IOI18_werewolf)C++17
15 / 100
216 ms28260 KiB
#include "werewolf.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pair<int, int> pii

const int MAX = 3003;
int n, m, q;
vector<int> g[MAX];
bitset<MAX> vis1, vis2;

void dfs1(int node, int p, int l){
    vis1[node] = 1;
    for(int to : g[node]){
        if(vis1[to] || to < l) continue;
        dfs1(to, node, l);
    }
}

void dfs2(int node, int p, int r){
    vis2[node] = 1;
    for(int to : g[node]){
        if(vis2[to] || to > r) continue;
        dfs2(to, node, r);
    }
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y,
                            vector<int> S, vector<int> E,
                            vector<int> L, vector<int> R){
    q = S.size();
    n = N;
    m = X.size();
    for(int i = 0; i < m; i++){
        g[X[i]].push_back(Y[i]);
        g[Y[i]].push_back(X[i]);
    }
    vector<int> ans;
    for(int i = 0; i < q; i++){
        vis1.reset();
        vis2.reset();
        dfs1(S[i], S[i], L[i]);
        dfs2(E[i], E[i], R[i]);
        if((vis1 & vis2).count()){
            ans.push_back(1);
        }
        else{
            ans.push_back(0);
        }
    }
    return ans;
}

Compilation message (stderr)

werewolf.cpp:7:9: warning: ISO C++11 requires whitespace after the macro name
    7 | #define pair<int, int> pii
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...