Submission #852915

#TimeUsernameProblemLanguageResultExecution timeMemory
852915Trisanu_DasThe Xana coup (BOI21_xanadu)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n,f[1000005][2][2],C[1000005]; vector <int> G[1000005]; void dfs(int u, int p){ for(int i = 0; i <= 1; i++){ f[u][i][C[u]^i] = i; f[u][i][C[u]^i^1] = n + 1; } for(int v : G[u])if(v!=fa){ dfs(v,u); for(int i = 0; i <= 1; i++){ int f0=f[u][i][0],f1=f[u][i][1]; f[u][i][0]=min(n+1,min(f0+f[v][0][i],f1+f[v][1][i])); f[u][i][1]=min(n+1,min(f0+f[v][1][i],f1+f[v][0][i])); } } } int main(){ cin >> n; for(int i = 2; i <= n; i++){ int u,v; cin >> u >> v; G[u].push_back(v),G[v].push_back(u); } rep(i,1,n)cin >> C[i]; dfs(1,0); int ans=min(f[1][0][0],f[1][1][0]); if(ans>n) cout << "impossible\n"; else cout << ans << '\n'; }

Compilation message (stderr)

xanadu.cpp: In function 'void dfs(int, int)':
xanadu.cpp:11:28: error: 'fa' was not declared in this scope; did you mean 'f'?
   11 |     for(int v : G[u])if(v!=fa){
      |                            ^~
      |                            f
xanadu.cpp: In function 'int main()':
xanadu.cpp:27:9: error: 'i' was not declared in this scope
   27 |     rep(i,1,n)cin >> C[i];
      |         ^
xanadu.cpp:27:5: error: 'rep' was not declared in this scope
   27 |     rep(i,1,n)cin >> C[i];
      |     ^~~