이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
void dfsup(int node, list<int> *adj, int edge , int *visited){
//cout << "dfsup(" << node << ")" << endl;
visited[node] = 1;
for (list<int>::iterator it = adj[node].begin(); it != adj[node].end(); ++it){
if (visited[*it]) continue;
if (*it < edge) continue;
dfsup(*it, adj, edge, visited);
}
}
int dfsdown(int node, list<int> *adj, int edge, int *visited){
//cout << "dfsdown(" << node << ")" << endl;
visited[node] = 2;
for (list<int>::iterator it = adj[node].begin(); it != adj[node].end(); ++it){
if (*it > edge) continue;
if (visited[*it] == 1) return 1;
if (visited[*it]) continue;
if (dfsdown(*it, adj, edge, visited)) return 1;
}
return 0;
}
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();
vector<int> A(Q);
list<int> adj[N];
for (int i = 0; i < (int)X.size(); i++){
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
for (int i = 0; i < Q; i++){
int l = L[i];
int r = R[i];
int s = S[i];
int e = E[i];
/*cout << "l: " << l;
cout << " r: " << r;
cout << " s: " << s;
cout << " e: " << e;
cout << endl;*/
int visited[N];
for (int q = 0; q < N; q++) visited[q] = 0;
dfsup(s, adj, l, visited);
int a = dfsdown(e, adj, r, visited);
A[i] = a;
}
return A;
}
/*
vector<int> A(Q);
for (int i = 0; i < Q; ++i) {
A[i] = 0;
}
return A;
*/
# | 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... |