답안 #831569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831569 2023-08-20T10:27:59 Z caganyanmaz 늑대인간 (IOI18_werewolf) C++17
0 / 100
124 ms 48164 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(s.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++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 14840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 14840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 124 ms 48164 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 14840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -