이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int n;
vector<int> rep, tam;
vector<int> ans;
void uni(int a, int b);
int find(int 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){
n = N;
int q = L.size();
int m = X.size();
ans = vector<int> (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++){
rep = vector<int> (2 * n);
tam = vector<int> (2 * n, 1);
for(int i = 0; i < 2 * n; i++)
rep[i] = i;
for(int j = 0; j < m; j++){
if(X[j] <= R[i] && Y[j] <= R[i]){
uni(2 * X[j] + 1, 2 * Y[j] + 1);
}
if(X[j] >= L[i] && Y[j] >= L[i]){
uni(2 * X[j], 2 * Y[j]);
}
}
for(int j = L[i]; j <= R[i]; j++)
uni(2 * j, 2 * j + 1);
ans[i] = find(2 * S[i]) == find(2 * E[i] + 1);
}
return ans;
}
void uni(int a, int b){
a = find(a);
b = find(b);
if(a == b) return;
if(tam[a] < tam[b]) swap(a, b);
rep[b] = a;
tam[a] += tam[b];
}
int find(int a){
if(a == rep[a]) return a;
return find(rep[a]);
}
# | 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... |