제출 #1032905

#제출 시각아이디문제언어결과실행 시간메모리
1032905MalixThe Xana coup (BOI21_xanadu)C++14
30 / 100
111 ms18880 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> pi; typedef vector<pi> pii; typedef tuple<int,int,int> tii; typedef vector<ll> li; typedef vector<li> lii; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define MP make_pair #define LSOne(s) ((s)&(-s)) ll INF=1e18+10; int inf=1e7+10; ll M=1e9+7; int n; vii a; vector<vii> dp; vi p,b; void solve(int node){ int o1=inf,o2=inf,e1=0,e2=0;int k=0; for(auto u:a[node]){ if(p[node]==u)continue;k++; p[u]=node; solve(u); int o1t=min(o1+dp[0][1][u],e1+dp[1][1][u]); int o2t=min(o2+dp[0][0][u],e2+dp[1][0][u]); int e1t=min(e1+dp[0][1][u],o1+dp[1][1][u]); int e2t=min(e2+dp[0][0][u],o2+dp[1][0][u]); o1=o1t;o2=o2t;e1=e1t;e2=e2t; } if(b[node]==0){ dp[0][0][node]=e2; dp[1][0][node]=1+o1; dp[1][1][node]=1+e1; dp[0][1][node]=o2; } else{ dp[0][0][node]=o2; dp[1][0][node]=1+e1; dp[1][1][node]=1+o1; dp[0][1][node]=e2; } } int main() { //ios::sync_with_stdio(0); //cin.tie(0); //freopen("test_input.txt", "r", stdin); //freopen("test_output.txt", "w", stdout); cin>>n; a.resize(n);p.resize(n,-1);b.resize(n); dp.resize(2,vii(2,vi(n))); REP(i,0,n-1){ int x,y; cin>>x>>y; x--;y--; a[x].PB(y); a[y].PB(x); } REP(i,0,n)cin>>b[i]; solve(0); cerr<<dp[0][0][0]<<" "<<dp[1][0][0]<<"\n"; int ans=min(dp[0][0][0],dp[1][0][0]); if(ans>=inf)cout<<"impossible"; else cout<<ans; }

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

xanadu.cpp: In function 'void solve(int)':
xanadu.cpp:32:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |         if(p[node]==u)continue;k++;
      |         ^~
xanadu.cpp:32:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |         if(p[node]==u)continue;k++;
      |                                ^
#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...