#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
const int Nx = 200000;
vector<int> gr[Nx];
struct node{
int x;
bool form; // 0 human 1 werewolf
node(){}
node(int _x,bool _form){
x = _x;
form = _form;
}
};
vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R) {
int Q = S.size();
int M = X.size();
vector<int> ans(Q,0);
for(int i=0;i<M;i++){
gr[X[i]].push_back(Y[i]);
gr[Y[i]].push_back(X[i]);
}
for(int i=0;i<Q;i++){
int s = S[i],e = E[i], l = L[i], r = R[i];
//cerr<< s<<" "<<e<<" "<<l<<" "<<r<<": ";
queue<node> q;
vector<vector<bool>> vis(N+1,vector<bool>(3,0));
q.push(node(s,0));
while(!q.empty()){
node p = q.front();
q.pop();
cerr << p.x <<" "<<p.form << '\n';
if(p.x == e && p.form){
ans[i] = 1;
break;
}
if(vis[p.x][p.form] || (p.form && p.x > r) || (!p.form && p.x < l))continue;
vis[p.x][p.form] = 1;
for(auto u:gr[p.x]){
cerr<<u<<"\n";
if(p.form){
//werewolf
if(u <= r && !vis[u][1]){
q.push({u,1});
}
}else{
// human
if(p.x >= l && p.x <= r && u >= l && !vis[u][1]){
q.push({u,1});
}
if(u >= l && !vis[u][0]){
q.push({u,0});
}
}
}
}
//cerr<<ans[i] << '\n';
}
return ans;
}
/*
4 3 1 2
h h h |w
0 1 2 3 4 5
H H | W W W
4 3 1 5 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
5268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
5268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4041 ms |
45364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
5268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |