Submission #434580

# Submission time Handle Problem Language Result Execution time Memory
434580 2021-06-21T12:24:34 Z Azimjon Werewolf (IOI18_werewolf) C++17
0 / 100
167 ms 21192 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), used2(N, 0);

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

	function<void(int)> dfsw = [&](int x) {
		used2[x] = 1;
		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 != 0;
}

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 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 21192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -