Submission #831567

# Submission time Handle Problem Language Result Execution time Memory
831567 2023-08-20T10:27:15 Z caganyanmaz Werewolf (IOI18_werewolf) C++17
0 / 100
125 ms 48152 KB
#include <bits/stdc++.h>
#define pb push_back
#include "werewolf.h"

//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
constexpr static int MXN = 3e5;
constexpr static int MXST = MXN<<1;
constexpr static int INF = 1e6;

using namespace std;
bitset<MXN> visited[2];
vector<int> g[MXN];

bool valid(int node, int l, int r, int state)
{
	return (state == 0 && node >= l) || (state == 1 && node <= r);
}

bool dfs(int node, int t, int l, int r, int state)
{
	visited[state][node] = true;
	if (!valid(node, l, r, state))
		return false;
	debug(node, t, l, r, state);
	if (state == 1 && node == t)
		return true;
	if (state == 0 && !visited[node][1] && dfs(node, t, l, r, 1))
		return true;
	for (int c : g[node])
		if (!visited[state][c] && dfs(c, t, l, r, state))
			return true;
	return false;

}

vector<int> check_validity(int n, vector<int> x, vector<int> y, vector<int> s, vector<int> e, vector<int> L, vector<int> R) {
	for (int i = 0; i < x.size(); i++)
	{
		g[x[i]].pb(y[i]);
		g[y[i]].pb(x[i]);
	}
	vector<int> res(x.size());
	for (int i = 0; i < s.size(); i++)
	{
		debug("--------");
		visited[0].reset();
		visited[1].reset();
		res[i] = dfs(s[i], e[i], L[i], R[i], 0);
	}
	return res;
	

}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = 0; i < x.size(); i++)
      |                  ~~^~~~~~~~~~
werewolf.cpp:48:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  for (int i = 0; i < s.size(); i++)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 14804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 14804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 125 ms 48152 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 14804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -