Submission #729398

#TimeUsernameProblemLanguageResultExecution timeMemory
729398onepunchac168Swapping Cities (APIO20_swap)C++14
Compilation error
0 ms0 KiB
#include "swap.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; typedef pair <ll,ii> iii; ll n,m; ll parent[200005][20]; ll gg; struct DSU{ ll lab[200005]; bool check[200005]; ll tmp[200005]; ll countedge[200005]; void makeset(int u) { lab[u]=-1; check[u]=0; tmp[u]=-1; countedge[u]=0; } ll findset(int u) { if (lab[u]<0) { return u; } return lab[u]=findset(lab[u]); } void Union(int u,int v,ll w) { int r=findset(u); int s=findset(v); countedge[u]++; countedge[v]++; if (r==s) { if (check[r]==0) { check[r]=1; tmp[r]=w; } return; } if (lab[r]>lab[s]) { swap(r,s); } lab[r]+=lab[s]; lab[s]=r; if (check[r]!=0) } } dsu; ll solve(ll aa,ll bb) { if (aa==-1&&bb==-1) { return -1; } if (aa==-1) { return bb; } if (bb==-1) { return aa; } return min(aa,bb); } void dfs(int u,int vv) { for (auto v:vt[u]) { if (v==vv) { continue; } parent[v][0]=u; for (int i=1;i<=18;i++) { parent[v][i]=parent[parent[v][i-1]][i-1]; } dsu.tmp[v]=solve(dsu.tmp[v],dsu.tmp[u]); dfs(v,u); } } void init(int N, int M,std::vector<int> U, std::vector<int> V, std::vector<int> W) { n=N-1; m=M-1; gg=n; vector <iii> vt; for (int i=0;i<=2*n+1;i++) { dsu.makeset(i); tmp[i]=-1; } for (int i=0;i<=m;i++) { ll u=U[i]; ll v=V[i]; ll w=W[i]; vt.pb({w,{u,v}}); } sort (vt.begin(),vt.end()); for (auto v:vt) { dsu.Union(v.se.fi,v.se.se,v.fi); } dfs(gg,-1); } int getMinimumFuelCapacity(int X, int Y) { return 0; }

Compilation message (stderr)

swap.cpp: In member function 'void DSU::Union(int, int, ll)':
swap.cpp:59:5: error: expected primary-expression before '}' token
   59 |     }
      |     ^
swap.cpp: In function 'void dfs(int, int)':
swap.cpp:79:17: error: 'vt' was not declared in this scope; did you mean 'v'?
   79 |     for (auto v:vt[u])
      |                 ^~
      |                 v
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:102:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
  102 |         tmp[i]=-1;
      |         ^~~
      |         tm