Submission #835136

#TimeUsernameProblemLanguageResultExecution timeMemory
835136JohannWerewolf (IOI18_werewolf)C++14
0 / 100
4098 ms34908 KiB
#include "werewolf.h" #include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() int N, Q, M; vvi adj; vi S, E, L, R; struct unionfind { int size; vi arr; void init(int _size) { size = _size; arr.resize(size); iota(all(arr), 0); } int find(int i) { return arr[i] = (arr[i] == i) ? i : find(arr[i]); } void combine(int a, int b) { a = find(a), b = find(b); arr[a] = b; } }; std::vector<int> check_validity(int _N, std::vector<int> X, std::vector<int> Y, std::vector<int> _S, std::vector<int> _E, std::vector<int> _L, std::vector<int> _R) { N = _N, Q = sz(_S), M = sz(X); S = _S, E = _E, L = _L, R = _R; adj.clear(); adj.resize(N); for (int i = 0; i < M; ++i) adj[X[i]].push_back(Y[i]), adj[Y[i]].push_back(X[i]); std::vector<int> A(Q); for (int q = 0; q < Q; ++q) { unionfind ufHuman, ufWolf; ufHuman.init(N), ufWolf.init(N); for (int i = 0; i < M; ++i) if (X[i] >= L[q] && Y[i] >= L[q]) ufHuman.combine(X[i], Y[i]); for (int i = 0; i < M; ++i) if (X[i] <= R[q] && Y[i] <= R[q]) ufHuman.combine(X[i], Y[i]); A[q] = 0; for (int i = 0; i < N; ++i) A[q] |= (ufHuman.find(S[q]) == ufHuman.find(i) && ufWolf.find(E[q]) == ufWolf.find(i)); } return A; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...