#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 < n; 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:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
14804 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
14804 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
154 ms |
48176 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
14804 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |