제출 #718703

#제출 시각아이디문제언어결과실행 시간메모리
718703lam도로 폐쇄 (APIO21_roads)C++14
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 10; typedef pair<int,int> ii; #define ff first #define ss second int n,k; ll dp[2][maxn]; vector <ii> adj[maxn]; priority_queue<ll,vector<ll>,greater<ll>> pq; void dfs(int x, int p) { ll sum = 0LL; vector <ll> tmp; for (ii i:adj[x]) if (i.ff!=p) { dfs(i.ff,x); sum += dp[0][i.ff]; tmp.push_back(dp[1][i.ff]+i.ss-dp[0][i.ff]); } sort(tmp.begin(),tmp.end(),greater<ll>()); vector <ll> tmp2 = tmp; dp[0][x] = sum; while (!tmp.empty()&&(tmp.size()>k||(tmp.back() < 0))) { dp[0][x] += tmp.back(); tmp.pop_back(); } dp[1][x] = sum; while (!tmp2.empty()&&(tmp2.size()>k+1||(tmp2.back()<0))) { dp[1][x] += tmp2.back(); tmp2.pop_back(); } } vector <ll> minimum_closure_costs(int N, int vector <int>U, vector<int>V, vector<int>W) { n=N; for (int i=0; i<n; i++) adj[i].clear(); for (int i=0; i<n-1; i++) { int u=U[i]; int v=V[i]; int w=W[i]; pq.push(w); } vector <ll> ans; ll num = 0LL; for (int k=n-1; k>=0; k--) { while (pq.size() > k) { num+=pq.top(); pq.pop(); } ans.push_back(num); } reverse(ans.begin(),ans.end()); return ans; }

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

roads.cpp: In function 'void dfs(int, int)':
roads.cpp:28:37: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     while (!tmp.empty()&&(tmp.size()>k||(tmp.back() < 0)))
      |                           ~~~~~~~~~~^~
roads.cpp:34:39: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while (!tmp2.empty()&&(tmp2.size()>k+1||(tmp2.back()<0)))
      |                            ~~~~~~~~~~~^~~~
roads.cpp: At global scope:
roads.cpp:41:58: error: expected unqualified-id before 'U'
   41 | vector <ll> minimum_closure_costs(int N, int vector <int>U, vector<int>V, vector<int>W)
      |                                                          ^
roads.cpp:41:58: error: expected ')' before 'U'
   41 | vector <ll> minimum_closure_costs(int N, int vector <int>U, vector<int>V, vector<int>W)
      |                                  ~                       ^
      |                                                          )
roads.cpp:41:58: error: expected initializer before 'U'