QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#878286#9696. Analysisucup-team5234#Compile Error//C++23833b2025-02-01 14:37:442025-02-01 14:37:44

Judging History

This is the latest submission verdict.

  • [2025-02-06 00:45:32]
  • hack成功,自动添加数据
  • (/hack/1517)
  • [2025-02-01 14:37:44]
  • Judged
  • [2025-02-01 14:37:44]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if(N <= 2){
        cout << 0 << "\n";
        return;
    }
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; i ++){
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ll ans = 0;
    ll mx = 0;
    auto dfs = [&](auto&& dfs, int cur, int pre, int len){
        if(G[cur].size() >= 3){
            ans += min(a * len, b);
            mx = max(mx, min(a * len, b));
        }
        for(auto e : G[cur]){
            if(pre == e)continue;
            dfs(dfs, e, cur, len + 1);
        }
    };
    for(int i = 0; i < N; i++){
        dfs(dfs, i, -1, 0);
    }
    cout << ans - mx << endl;
}

Details

answer.code: In function ‘int main()’:
answer.code:10:9: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   10 |         return;
      |         ^~~~~~
answer.code: In lambda function:
answer.code:24:24: error: ‘a’ was not declared in this scope
   24 |             ans += min(a * len, b);
      |                        ^
answer.code:24:33: error: ‘b’ was not declared in this scope
   24 |             ans += min(a * len, b);
      |                                 ^
answer.code: In instantiation of ‘main()::<lambda(auto:58&&, int, int, int)> [with auto:58 = main()::<lambda(auto:58&&, int, int, int)>&]’:
answer.code:33:12:   required from here
   33 |         dfs(dfs, i, -1, 0);
      |         ~~~^~~~~~~~~~~~~~~
answer.code:29:16: error: use of ‘main()::<lambda(auto:58&&, int, int, int)> [with auto:58 = main()::<lambda(auto:58&&, int, int, int)>&]’ before deduction of ‘auto’
   29 |             dfs(dfs, e, cur, len + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~