Submission #141292

#TimeUsernameProblemLanguageResultExecution timeMemory
141292MinnakhmetovWerewolf (IOI18_werewolf)C++14
7 / 100
209 ms21196 KiB
#include "werewolf.h" using namespace std; #define ll long long const int N = 205; int w[N]; int findSet(int v) { return w[v] < 0 ? v : w[v] = findSet(w[v]); } void connect(int a, int b) { a = findSet(a); b = findSet(b); if (a != b) { if (w[a] > w[b]) swap(a, b); w[a] += w[b]; w[b] = a; } } 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> ans(q); for (int i = 0; i < m; i++) { if (x[i] > y[i]) { swap(x[i], y[i]); } } for (int i = 0; i < q; i++) { fill(w, w + n + n, -1); for (int j = 0; j < m; j++) { if (x[j] >= l[i]) connect(x[j], y[j]); if (y[j] <= r[i]) connect(x[j] + n, y[j] + n); } for (int j = l[i]; j <= r[i]; j++) { if (findSet(s[i]) == findSet(j) && findSet(e[i] + n) == findSet(j + n)) { ans[i] = 1; break; } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...