Submission #1088231

# Submission time Handle Problem Language Result Execution time Memory
1088231 2024-09-14T07:02:02 Z Rolo678 Aesthetic (NOI20_aesthetic) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<pair<long long,pair<int,int>>>>g(3e5+5);
vector<long long>dp2(3e5+5,1e9+5);
 vector<long long>dp(3e5+5,0);
void dfs(int v=1,int p=-1,int w=0)
{
  if(p==-1)dp[v] = 0;
  else dp[v] = dp[p] + w;
  for(auto u : g[v])
  {
    if(p != u.second.first)
    {
      dp2[u.second.first]= min(dp2[v],u.second.second)
      dfs(u.second.first,v,u.first);
     
    }
  }
}
 
int main()
{
  int n,m;
  cin >> n>>m;
  cin >> n >> m;
  vector<long long>mx(m+2);
  for(int i = 1;i<n;i++)
  {
    int a,b,w;
    cin >> a >> b >> w;
    g[a].push_back({w,{b,i}});
    g[b].push_back({w,{a,i}});
    mx[i] = w;
  }
  
  for(int i = n-1;i> 0;i--)
  {
    mx[i] = max(mx[i+1],mx[i]);
  }
  
  dfs();
  
  long long ans = dp[n] + mx[dp2[n]+1];
  cout << ans;
}

Compilation message

Aesthetic.cpp: In function 'void dfs(long long int, long long int, long long int)':
Aesthetic.cpp:15:55: error: expected ';' before 'dfs'
   15 |       dp2[u.second.first]= min(dp2[v],u.second.second)
      |                                                       ^
      |                                                       ;
   16 |       dfs(u.second.first,v,u.first);
      |       ~~~                                              
At global scope:
cc1plus: error: '::main' must return 'int'