제출 #906052

#제출 시각아이디문제언어결과실행 시간메모리
906052MathiasThe Xana coup (BOI21_xanadu)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN = 1e5+7; const long long INF = 1e9+7; long long dp[MAXN][3][3]; bool t[MAXN], visited[MAXN]; vector<long long> g[MAXN]; long long n,a,b,c,d; void DFS(int x){ visited[x]=1; if(t[x]){ dp[x][1][0]=1; dp[x][0][1]=0; } else{ dp[x][1][1]=1; dp[x][0][0]=0; } for(int i=0;i<g[x].size();i++){ if(visited[g[x][i]]==1) continue; int s=g[x][i]; DFS(s); a=dp[x][0][0], b=dp[x][0][1], c=dp[x][1][0], d=dp[x][1][1]; dp[x][0][0]=min(a+dp[s][0][0], b+dp[s][1][0]); dp[x][0][1]=min(b+dp[s][0][0], a+dp[s][1][0]); dp[x][1][0]=min(c+dp[s][0][1], d+dp[s][1][1]); dp[x][1][1]=min(d+dp[s][0][1], c+dp[s][1][1]); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<n;i++){ cin>>a>>b; g[a].push_back(b); g[b].push_back(a); } for(int i=1;i<=n;i++) cin>>t[i]; for(int i=1;i<=n;i++){ dp[i][0][0]=INF; dp[i][1][0]=INF; dp[i][0][1]=INF; dp[i][1][1]=INF; } DFS(1,0); if(dp[1][1][0]>n and dp[1][0][0]>n) cout<<"impossible\n"; else cout<<min(dp[1][1][0], dp[1][0][0])<<'\n'; return 0; }

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

xanadu.cpp: In function 'void DFS(int)':
xanadu.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<g[x].size();i++){
      |              ~^~~~~~~~~~~~
xanadu.cpp: In function 'int main()':
xanadu.cpp:46:9: error: too many arguments to function 'void DFS(int)'
   46 |  DFS(1,0);
      |         ^
xanadu.cpp:10:6: note: declared here
   10 | void DFS(int x){
      |      ^~~