제출 #598881

#제출 시각아이디문제언어결과실행 시간메모리
598881fuad27늑대인간 (IOI18_werewolf)C++17
15 / 100
4045 ms20756 KiB
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
struct DSU {
	vector<int> e;
	DSU(int N) { e = vector<int>(N, -1); }
	int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
	bool same_set(int a, int b) { return get(a) == get(b); }
	int size(int x) { return -e[get(x)]; }
	bool unite(int x, int y) {
		x = get(x), y = get(y);
		if (x == y) return false;
		if (e[x] > e[y]) swap(x, y);
		e[x] += e[y]; e[y] = x; return true;
	}
};
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();
  std::vector<int> A(Q);
  for (int j = 0; j < Q; ++j) {
	  DSU l(N+1), r(N+1);
	  for(int i = 0;i<(int)X.size();i++) {
		if(X[i] <= R[j] and Y[i]<=R[j])l.unite(X[i], Y[i]);
		if(X[i]>=L[j] and Y[i]>=L[j])r.unite(X[i], Y[i]);
	  }
	  for(int i = L[j];i<=R[j];i++) {
		if(l.same_set(E[j], i) and r.same_set(S[j],i))A[j]=1;
	  }
  }
  return A;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...