제출 #1070127

#제출 시각아이디문제언어결과실행 시간메모리
1070127errayThe Xana coup (BOI21_xanadu)C++17
100 / 100
59 ms18524 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "/home/ioi/contests/debug.h" #else #define debug(...) void(37) #endif int main() { ios_base::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<vector<int>> g(N); for (int i = 0; i < N - 1; ++i) { int A, B; cin >> A >> B; --A, --B; g[A].push_back(B); g[B].push_back(A); } vector<int> S(N); for (int i = 0; i < N; ++i) { cin >> S[i]; } using D = array<array<int, 2>, 2>; auto Dfs = [&](int v, auto&& Dfs) -> D { D cur{}; for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) cur[i][j] = N + 1; cur[S[v]][0] = 0; cur[S[v] ^ 1][1] = 1; bool leaf = true; for (auto u : g[v]) { g[u].erase(find(g[u].begin(), g[u].end(), v)); auto c = Dfs(u, Dfs); D next{}; for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) next[i][j] = N + 1; for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int ii = 0; ii < 2; ++ii) { next[i ^ ii][j] = min(next[i ^ ii][j], cur[i][j] + c[j][ii]); } swap(next, cur); leaf = false; } return cur; }; auto ans = Dfs(0, Dfs); int mn = min(ans[0][0], ans[0][1]); cout << (mn <= N ? to_string(mn) : "impossible") << '\n'; }

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

xanadu.cpp: In instantiation of 'main()::<lambda(int, auto:23&&)> [with auto:23 = main()::<lambda(int, auto:23&&)>&; D = std::array<std::array<int, 2>, 2>]':
xanadu.cpp:48:24:   required from here
xanadu.cpp:34:10: warning: variable 'leaf' set but not used [-Wunused-but-set-variable]
   34 |     bool leaf = true;
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...