Submission #434561

# Submission time Handle Problem Language Result Execution time Memory
434561 2021-06-21T12:05:11 Z Azimjon Werewolf (IOI18_werewolf) C++17
0 / 100
171 ms 21240 KB
#include "werewolf.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 3003;

vector<int> g[N];

int query(int u, int v, int l, int r) {
	vector<int> used(N, 0);
	auto used2 = used;

	function<void(int)> dfsh = [&](int x) {
		used[x] = true;
		for (int e : g[x]) {
			if (!used[e] && e >= l) dfsh(e);
		}
	};

	function<void(int)> dfsw = [&](int x) {
		used2[x] = true;
		for (int e : g[x]) {
			if (!used2[e] && e <= r) dfsw(e);
		}
	};

	dfsh(u);

	dfsw(v);

	int flag = 0;
	for (int i = 0; i < N; i++) {
		flag |= (used[i] && used2[i]);
	}

	return flag;
}

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 i = 0; i < N; i++) {
		g[X[i]].push_back(Y[i]);
		g[Y[i]].push_back(X[i]);
	}

	for (int i = 0; i < Q; i++) {
		A[i] = query(S[i], E[i], L[i], R[i]);
	}

	return A;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 171 ms 21240 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -