This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=300007;
ll n,m,k;
vector<int>g[N];
bool used[N];
bool used2[N];
void dfs1(int v, int btm){
used[v]=true;
for(int to:g[v]){
if(!used[to]&&to>=btm){
dfs1(to,btm);
}
}
}
bool dfs2(int v, int top){
if(used[v])return true;
used2[v]=true;
for(int to:g[v]){
if(!used2[to]&&to<=top){
if(dfs2(to,top)){
return true;
}
}
}
return false;
}
vector<int> check_validity(int NN, vector<int> X, vector<int> Y,
vector<int> S, vector<int> E,
vector<int> L, vector<int> R) {
n=NN;
m=X.size();
k=S.size();
for(int i=0;i<m;i++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
vector<int>ans;
if(n<=3000&&k<=3000&&m<=6000){
for(int i=0;i<k;i++){
dfs1(S[i],L[i]);
ans.push_back(dfs2(E[i],R[i]));
fill(used,used+n+1,false);
fill(used2,used2+n+1,false);
}
return ans;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |