Submission #1024400

#TimeUsernameProblemLanguageResultExecution timeMemory
1024400Ahmed_SolymanStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<int>>adj; vector<int>l,r,val; int mark=0; void dfs(int node,int par,int dep){ l[node]=mark++; for(auto i:adj[node]) if(i!=par)dfs(i,node,1-dep); r[node]=mark++; val[node]=(dep?l[node]:r[node]); } vector<int> label(int n, int k, vector<int> u, vector<int> v){ mark=0; l=r=val=vector<int>(n); adj=vector<vector<int>>(n); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,0,1); vector<int>p(n); for(int i=0;i<n;i++)p[i]=i; sort(p.begin(),p.end(),[&](int a,int b){ return val[a]<val[b]; }}; vector<int>ret(n); for(int i=0;i<n;i++){ ret[p[i]]=i; } return ret; } int find_next_station(int s, int t,vector<int> c){ int m=(int)c.size(); if(s==0){ for(int i=m-1;i>=0;i--){ int in=(i==0?s+1:c[i-1]+1); int out=c[i]; if(t>in && t<out){ return c[i]; } } assert(0); } if(s<c[0]){///given is the in[s] int p=c[m-1]; for(int i=m-2;i>=0;i--){ int in=(i==0?s+1:c[i-1]+1); int out=c[i]; if(t>in && t<out){ return c[i]; } } return p; } else{///given is the out[s] int p=c[0]; for(int i=1;i<m;i++){ int in=c[i]; int out=(i==m-1?s-1:c[i+1]-1); if(t>in && t<out){ return c[i]; } } return p; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:29:6: error: expected ')' before '}' token
   29 |     }};
      |      ^
      |      )
stations.cpp:27:9: note: to match this '('
   27 |     sort(p.begin(),p.end(),[&](int a,int b){
      |         ^
stations.cpp:29:6: warning: no return statement in function returning non-void [-Wreturn-type]
   29 |     }};
      |      ^
stations.cpp: At global scope:
stations.cpp:30:20: error: 'n' was not declared in this scope
   30 |     vector<int>ret(n);
      |                    ^
stations.cpp:31:5: error: expected unqualified-id before 'for'
   31 |     for(int i=0;i<n;i++){
      |     ^~~
stations.cpp:31:17: error: 'i' does not name a type
   31 |     for(int i=0;i<n;i++){
      |                 ^
stations.cpp:31:21: error: 'i' does not name a type
   31 |     for(int i=0;i<n;i++){
      |                     ^
stations.cpp:34:5: error: expected unqualified-id before 'return'
   34 |     return ret;
      |     ^~~~~~
stations.cpp:35:1: error: expected declaration before '}' token
   35 | }
      | ^