제출 #278707

#제출 시각아이디문제언어결과실행 시간메모리
278707jairRS늑대인간 (IOI18_werewolf)C++17
컴파일 에러
0 ms0 KiB
#include "werewolf.h" #include <set> #include <vector> #include <algorithm> using namespace std; set<int> adj[3004]; int memo[3004][2]; int dp(int curcity, int endcity, int l, int r, vector<bool> 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; if (memo[curcity][form] != -1) return memo[curcity][form]; visited[curcity] = true; int res = 0; for (int adjcity : adj[curcity]) { if (visited[adjcity]) { continue; } res += dp(adjcity, endcity, l, r, visited, form); } if (form != 1) { vector<bool> nvisited(visited.size()); res += dp(curcity, endcity, l, r, nvisited, 1); } memo[curcity][form] = res; 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<bool> nvisited(N); memset(memo, -1, sizeof(memo)); int ans = dp(S[i], E[i], L[i], R[i], nvisited); ans = min(ans, 1); A[i] = ans; } return A; }

컴파일 시 표준 에러 (stderr) 메시지

werewolf.cpp: In function 'int dp(int, int, int, int, std::vector<bool>, int)':
werewolf.cpp:12:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   12 |  if (form == 0 & curcity < l)
      |      ~~~~~^~~~
werewolf.cpp:14:11: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   14 |  if (form == 1 & curcity > r)
      |      ~~~~~^~~~
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:59:3: error: 'memset' was not declared in this scope
   59 |   memset(memo, -1, sizeof(memo));
      |   ^~~~~~
werewolf.cpp:5:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;