제출 #961435

#제출 시각아이디문제언어결과실행 시간메모리
961435zeta7532도로 폐쇄 (APIO21_roads)C++17
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; const ll mod = 998244353; const ll INF = 1LL<<60; #define fi first #define se second #define rep(i,n) for(ll i=0;i<n;i++) #define all(x) x.begin(),x.end() #define faster ios::sync_with_stdio(false);cin.tie(nullptr) #include <vector> std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector<vector<ll>> dp(N,vector<ll>(N+1,0)); vector<vector<pair<ll,ll>>> G(N); rep(i,N-1){ U[i]--,V[i]--; G[U[i]].push_back({V[i],W[i]}); G[V[i]].push_back({U[i],W[i]}); } vector<ll> ans(N,0); rep(deg,N){ function<void(ll)> dfs=[&](ll v,ll par){ for(auto e:G[v]){ dfs(e.fi,v); } } } return ans; }

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

roads.cpp: In lambda function:
roads.cpp:32:19: error: no match for call to '(std::function<void(long long int)>) (long long int&, ll&)'
   32 |         dfs(e.fi,v);
      |                   ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:2:
/usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {long long int}]'
  617 |     function<_Res(_ArgTypes...)>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/std_function.h:617:5: note:   candidate expects 1 argument, 2 provided
roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:35:5: error: conversion from 'minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)::<lambda(ll, ll)>' to non-scalar type 'std::function<void(long long int)>' requested
   35 |     }
      |     ^