제출 #984200

#제출 시각아이디문제언어결과실행 시간메모리
984200Alkaser_ID도로 폐쇄 (APIO21_roads)C++17
0 / 100
25 ms15964 KiB
#include "roads.h" using namespace std; #include <bits/stdc++.h> typedef long long ll; vector<ll> adj[200005]; std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { ll n = N; bool sb1 = true, sb2 = true; for(int i=0;i<n-1;i++) { if(U[i] != 0) sb1 = false; if(U[i] = i || V[i] != i+1) sb2 = false; ll u,v; adj[u].push_back(v); adj[v].push_back(u); } if(sb1){ vector<ll> f; for(ll i=0;i<n-1;++i) f.push_back(W[i]); sort(f.begin(),f.end()); ll res = 0; vector<ll> ans; ans.push_back(res); for(ll i=0;i<n-1;++i){ res += f[i]; ans.push_back(res); } return ans; } if(sb2){ ll sm =0; for(ll i=0;i<n-1;++i) sm += W[i]; vector<ll> ans; ans.push_back(sm); vector<ll> dp0(n+3,0),dp1(n+3,0); dp0[0] = 0; dp1[0] = W[0]; for(ll i=1;i<n-1;++i){ dp0[i] = dp1[i-1]; dp1[i] = min(dp0[i-1],dp1[i-1]) + W[i]; } ans.push_back(min(dp0[n-1],dp1[n-1])); for(ll i=2;i<n;++i) ans.push_back(0); return ans; } }

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

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:14:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   14 |         if(U[i] = i || V[i] != i+1) sb2 = false;
roads.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
roads.cpp:16:14: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |         adj[u].push_back(v);
      |         ~~~~~^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...