This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "werewolf.h"
using namespace std;
#define ll long long
const int N = 4e5 + 5;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |