제출 #295890

#제출 시각아이디문제언어결과실행 시간메모리
295890SeDunion늑대인간 (IOI18_werewolf)C++17
15 / 100
4025 ms41920 KiB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5;
vector<int>g[MAXN];
int ds[MAXN], de[MAXN];
void dfss (int v, int bound) {
	if (v < bound) return;
	ds[v] = 1;
	for (int to : g[v]) if (!ds[to]) dfss (to, bound);
}
void dfse (int v, int bound) {
	if (v > bound) return;
	de[v] = 1;
	for (int to : g[v]) if (!de[to]) dfse (to, bound);
}
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 M = X.size();
	for (int i = 0 ; i < M ; ++ i) {
		g[X[i]].push_back (Y[i]);
		g[Y[i]].push_back (X[i]);
	}
	int Q = S.size();
	vector<int>ans(Q);
	for (int i = 0 ; i < Q ; ++ i) {
		int s = S[i], e = E[i];
		for (int j = 0 ; j < N ; ++ j) {
			ds[j] = de[j] = 0;
		}
		dfss (s, L[i]);
		dfse (e, R[i]);
		for (int j = 0 ; j < N ; ++ j) {
			if (L[i] <= j && j <= R[i] && ds[j] && de[j]) ans[i] = 1;
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...