# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742079 | Ronin13 | Werewolf (IOI18_werewolf) | C++14 | 583 ms | 24232 KiB |
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"
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int nmax = 200001;
/*6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4
*/
vector <int> p(nmax), sz(nmax);
void make_set(int v){
p[v]= v;
sz[v] = 1;
}
int find_set(int v){
return p[v] == v ? v : p[v] = find_set(p[v]);
}
void union_sets(int a, int b){
a = find_set(a);
b = find_set(b);
if(a == b)
return;
if(sz[a] < sz[b])
swap(a, b);
p[b] = a;
sz[a] += sz[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) {
int Q = S.size();
int n = N;
std::vector<int> A(Q);
for (int i = 0; i < Q; ++i) {
for(int j = 0; j < N; j++){
make_set(j), make_set(n + j);
}
for(int j = 0; j < X.size(); j++){
int u = X[j], v = Y[j];
if(u <= R[i] && v <= R[i])
union_sets(u, v);
if(u >= L[i] && v >= L[i])
union_sets(u + n, v + n);
}
for(int x = L[i]; x <= R[i]; x++){
if(find_set(x) == find_set(E[i])){
if(find_set(x + n) == find_set(S[i] + n)) A[i] = 1;
}
}
}
return A;
}
Compilation message (stderr)
# | 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... |