제출 #861975

#제출 시각아이디문제언어결과실행 시간메모리
861975Trisanu_DasThe Xana coup (BOI21_xanadu)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int N, L[1000000], dp[1000000][2][2]; vector<int> e[MAXN]; void dfs(int i = 0, int p = -1) { for (int s = 0; s < 2; s++) { dp[i][s][L[i] ^ s] = s; dp[i][s][L[i] ^ s ^ 1] = N + 1; } for (int j : e[i]) if (j != p) { dfs(j, i); for (int s = 0; s < 2; s++) { int dp0 = dp[i][s][0], dp1 = dp[i][s][1]; dp[i][s][0] = min(N + 1, min(dp0 + dp[j][0][s], dp1 + dp[j][1][s])); dp[i][s][1] = min(N + 1, min(dp0 + dp[j][1][s], dp1 + dp[j][0][s])); } } } int main() { cin >> N; int A, B; for (int i = 0; i < N - 1; i++) { cin >> A >> B; A--, B--; e[A].push_back(B); e[B].push_back(A); } for (int i = 0; i < N; i++) cin >> L[i]; dfs(); int r = min(dp[0][0][0], dp[0][1][0]); if (r > N) cout << "impossible\n"; else cout << r << "\n"; }

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

xanadu.cpp:5:15: error: 'MAXN' was not declared in this scope
    5 | vector<int> e[MAXN];
      |               ^~~~
xanadu.cpp: In function 'void dfs(int, int)':
xanadu.cpp:12:16: error: 'e' was not declared in this scope
   12 |   for (int j : e[i])
      |                ^
xanadu.cpp: In function 'int main()':
xanadu.cpp:29:5: error: 'e' was not declared in this scope
   29 |     e[A].push_back(B);
      |     ^