#include <bits/stdc++.h>
#include "werewolf.h"
#define debug
#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
const int MAXN = 110 ;
const int MAXM = 210 ;
using namespace std ;
vector<int> adj[MAXN] ;
bool marc[MAXN] ;
// -----------------------------------
bool check( int val , int ref , bool comp ) { return (comp ? val > ref : val < ref ) ; }
bool dfs( int x , int dest, int ref , bool comp )
{
if( x == dest ) return true ;
marc[x] = true ;
bool myAns = false ;
for( int i : adj[x] )
if( (!marc[i] && check(i , ref , comp) ) || i == dest )
myAns |= dfs(i , dest, ref, comp) ;
return myAns ;
}
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 m = x.size() , q = s.size() ;
vector<int> ans ;
lp(i,0,m)
{
int a = x[i] , b = y[i] ;
adj[a].pb(b) ;
adj[b].pb(a) ;
}
lp(i,0,n)
{
debug("Adjacency of %d: " , i ) ;
for(int j : adj[i]) debug("%d " , j ) ;
debug("\n") ;
}
lp(i,0,q)
{
int S = s[i] , T = e[i] ;
int L = l[i] , R = r[i] ;
bool feasible = false ;
lp(j,L,R+1)
{
if( j == S || j == T ) continue ;
bool iCan = false ;
memset( marc , false , sizeof marc ) ;
iCan = dfs( j , T , L , 0 ) ;
memset( marc , false , sizeof marc ) ;
iCan &= dfs( j , S , R , 1 ) ;
if(iCan)
{
feasible = true ;
break ;
}
}
ans.pb( feasible ? 1 : 0 ) ;
}
return ans ;
}
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:61:31: warning: left operand of comma operator has no effect [-Wunused-value]
debug("Adjacency of %d: " , i ) ;
^
werewolf.cpp:62:37: warning: left operand of comma operator has no effect [-Wunused-value]
for(int j : adj[i]) debug("%d " , j ) ;
^
werewolf.cpp:63:15: warning: statement has no effect [-Wunused-value]
debug("\n") ;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
202 ms |
25816 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |