이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "werewolf.h"
#include <set>
#include <vector>
using namespace std;
set<int> adj[3004];
int dp(int curcity, int endcity, int l, int r, vector<int> visited, int form = 0)
{
if (form == 0 & curcity < l)
return 0;
if (form == 1 & curcity > r)
return 0;
if (curcity == endcity && form == 1)
return 1;
visited[curcity] = true;
int res = 0;
for (int adjcity : adj[curcity])
{
res += dp(adjcity, endcity, l, r, visited, form);
if (form == 0)
res += dp(adjcity, endcity, l, r, visited, 1);
}
return res;
}
std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> S, std::vector<int> E,
std::vector<int> L, std::vector<int> R)
{
int Q = S.size();
int M = X.size();
for (int i = 0; i < M; i++)
{
adj[X[i]].insert(Y[i]);
adj[Y[i]].insert(X[i]);
}
std::vector<int> A(Q);
for (int i = 0; i < Q; i++)
{
vector<int> nvisited(N);
int ans = dp(S[i], E[i], L[i], R[i], nvisited);
if (ans > 0)
A.push_back(1);
else if (ans == 0)
A.push_back(0);
}
return A;
}
컴파일 시 표준 에러 (stderr) 메시지
werewolf.cpp: In function 'int dp(int, int, int, int, std::vector<int>, int)':
werewolf.cpp:10:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
10 | if (form == 0 & curcity < l)
| ~~~~~^~~~
werewolf.cpp:12:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
12 | if (form == 1 & curcity > r)
| ~~~~~^~~~
# | 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... |