#include "werewolf.h"
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const ll N = 1e6+5 , inf = 2e9 + 7 , block = 1000;
const ll INF = 1e18 , mod = 1e9+7;
int p[N] , sz[N];
int get(int a){
if(p[a] == a) return a;
return p[a] = get(p[a]);
}
void merge(int a , int b){
a = get(a);
b = get(b);
if(a == b) return;
if(sz[a] < sz[b]) swap(a,b);
sz[a] += sz[b];
p[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) {
vector<int> ans;
for(int i = 0; i < s.size(); i++){
for(int j = 0; j < n; j++){
p[j] = j;
sz[j] = 1;
}
for(int j = 0; j < x.size(); j++){
if(x[j] >= l[i] && y[j] >= l[i]){
merge(x[j],y[j]);
}
if(x[j] <= r[i] && y[j] <= r[i]){
merge(x[j],y[j]);
}
}
int ok = 0;
if(get(s[i]) == get(e[i])) ok = 1;
ans.push_back(ok);
}
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... |