Submission #1316892

#TimeUsernameProblemLanguageResultExecution timeMemory
1316892exoworldgdRace (IOI11_race)C++20
Compilation error
0 ms0 KiB
=#include<bits/stdc++.h> #define ll long long #define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0) using namespace std; const int N=2e5+5,K=1e6+5; vector<array<int,2>>g[N]; int n,k,ans=1e9,sz[N],mn[K],del[N]; int dfs_sz(int u,int p){ sz[u]=1; for(auto[v,w]:g[u])if(v!=p&&!del[v])sz[u]+=dfs_sz(v,u); return sz[u]; } int centroid(int u,int p,int tot){ for(auto[v,w]:g[u])if(v!=p&&!del[v]&&sz[v]*2>tot)return centroid(v,u,tot); return u; } void dfs(int u,int p,int d,int e,vector<array<int,2>>&paths){ if(d>k)return; paths.push_back({d,e}); for(auto [v,w]:g[u])if(v!=p&&!del[v])dfs(v,u,d+w,e+1,paths); } void solve(int u){ int c=centroid(u,-1,dfs_sz(u,-1)); del[c]=1; vector<vector<array<int,2>>>all; for(auto[v,w]:g[c]){ if(del[v])continue; vector<array<int,2>>paths; dfs(v,c,w,1,paths),all.push_back(paths); for(auto[d,e]:paths)if(d<=k)ans=min(ans,mn[k-d]+e); } for(auto&paths:all)for(auto[d,e]:paths)if(d<=k)mn[d]=min(mn[d],e); for(auto&paths:all)for(auto[d,e]:paths)if(d<=k)mn[d]=1e9; for(auto[v,w]:g[c])if(!del[v])solve(v); } int best_path(int n_,int k_,int h[][2],int *l){ n=n_,k=k_,fill(mn,mn+k+1,1e9),mn[0]=0; for(int i=0;i<n-1;i++)g[h[i][0]].push_back({h[i][1],l[i]}),g[h[i][1]].push_back({h[i][0],l[i]}); solve(0); return ans==1e9?-1:ans; }

Compilation message (stderr)

race.cpp:1:2: error: stray '#' in program
    1 | =#include<bits/stdc++.h>
      |  ^
race.cpp:1:1: error: expected unqualified-id before '=' token
    1 | =#include<bits/stdc++.h>
      | ^
race.cpp:6:8: error: 'array' was not declared in this scope
    6 | vector<array<int,2>>g[N];
      |        ^~~~~
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:8: error: 'array' was not declared in this scope
race.cpp:6:1: error: 'vector' does not name a type
    6 | vector<array<int,2>>g[N];
      | ^~~~~~
race.cpp: In function 'int dfs_sz(int, int)':
race.cpp:10:23: error: 'g' was not declared in this scope
   10 |         for(auto[v,w]:g[u])if(v!=p&&!del[v])sz[u]+=dfs_sz(v,u);
      |                       ^
race.cpp: In function 'int centroid(int, int, int)':
race.cpp:14:23: error: 'g' was not declared in this scope
   14 |         for(auto[v,w]:g[u])if(v!=p&&!del[v]&&sz[v]*2>tot)return centroid(v,u,tot);
      |                       ^
race.cpp: At global scope:
race.cpp:17:41: error: 'array' was not declared in this scope
   17 | void dfs(int u,int p,int d,int e,vector<array<int,2>>&paths){
      |                                         ^~~~~
race.cpp:17:41: error: 'array' was not declared in this scope
race.cpp:17:41: error: 'array' was not declared in this scope
race.cpp:17:41: error: 'array' was not declared in this scope
race.cpp:17:34: error: 'vector' has not been declared
   17 | void dfs(int u,int p,int d,int e,vector<array<int,2>>&paths){
      |                                  ^~~~~~
race.cpp:17:40: error: expected ',' or '...' before '<' token
   17 | void dfs(int u,int p,int d,int e,vector<array<int,2>>&paths){
      |                                        ^
race.cpp: In function 'void dfs(int, int, int, int, int)':
race.cpp:19:9: error: 'paths' was not declared in this scope
   19 |         paths.push_back({d,e});
      |         ^~~~~
race.cpp:20:24: error: 'g' was not declared in this scope
   20 |         for(auto [v,w]:g[u])if(v!=p&&!del[v])dfs(v,u,d+w,e+1,paths);
      |                        ^
race.cpp: In function 'void solve(int)':
race.cpp:25:23: error: 'array' was not declared in this scope
   25 |         vector<vector<array<int,2>>>all;
      |                       ^~~~~
race.cpp:25:16: error: 'vector' was not declared in this scope
   25 |         vector<vector<array<int,2>>>all;
      |                ^~~~~~
race.cpp:25:29: error: expected primary-expression before 'int'
   25 |         vector<vector<array<int,2>>>all;
      |                             ^~~
race.cpp:26:23: error: 'g' was not declared in this scope
   26 |         for(auto[v,w]:g[c]){
      |                       ^
race.cpp:28:30: error: expected primary-expression before 'int'
   28 |                 vector<array<int,2>>paths;
      |                              ^~~
race.cpp:29:29: error: 'paths' was not declared in this scope
   29 |                 dfs(v,c,w,1,paths),all.push_back(paths);
      |                             ^~~~~
race.cpp:29:36: error: 'all' was not declared in this scope; did you mean 'll'?
   29 |                 dfs(v,c,w,1,paths),all.push_back(paths);
      |                                    ^~~
      |                                    ll
race.cpp:30:49: error: 'min' was not declared in this scope; did you mean 'mn'?
   30 |                 for(auto[d,e]:paths)if(d<=k)ans=min(ans,mn[k-d]+e);
      |                                                 ^~~
      |                                                 mn
race.cpp:32:24: error: 'all' was not declared in this scope; did you mean 'll'?
   32 |         for(auto&paths:all)for(auto[d,e]:paths)if(d<=k)mn[d]=min(mn[d],e);
      |                        ^~~
      |                        ll
race.cpp:32:62: error: 'min' was not declared in this scope; did you mean 'mn'?
   32 |         for(auto&paths:all)for(auto[d,e]:paths)if(d<=k)mn[d]=min(mn[d],e);
      |                                                              ^~~
      |                                                              mn
race.cpp:33:24: error: 'all' was not declared in this scope; did you mean 'll'?
   33 |         for(auto&paths:all)for(auto[d,e]:paths)if(d<=k)mn[d]=1e9;
      |                        ^~~
      |                        ll
race.cpp:34:23: error: 'g' was not declared in this scope
   34 |         for(auto[v,w]:g[c])if(!del[v])solve(v);
      |                       ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:37:19: error: 'fill' was not declared in this scope; did you mean 'll'?
   37 |         n=n_,k=k_,fill(mn,mn+k+1,1e9),mn[0]=0;
      |                   ^~~~
      |                   ll
race.cpp:38:31: error: 'g' was not declared in this scope
   38 |         for(int i=0;i<n-1;i++)g[h[i][0]].push_back({h[i][1],l[i]}),g[h[i][1]].push_back({h[i][0],l[i]});
      |                               ^