Submission #948267

#TimeUsernameProblemLanguageResultExecution timeMemory
948267LibRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include "race.h" using namespace std; vector <vector <pair <int,int> > > adj; vector <pair <int,int> > TVector; int SubtreeSize[300003]; int CurParent[300003]; int IteratedAdj[300003]; int Deleted[300003]; int Visited[300003]; int DistFromRoot[300003]; vector <int> CurRoots; vector <int> Centroids; long long ans=999999; int N,Tar; int cur; void DFS(){ vector <int> DFStack; CurRoots.clear(); for(int i=0;i<=N;i++){ CurParent[i]=-1; IteratedAdj[i]=0; SubtreeSize[i]=1; DistFromRoot[i]=0; } for(int i=0;i<N;i++){ if(!Deleted[i]&&!Visited[i]){ DFStack.push_back(i); CurRoots.push_back(i); Visited[i]=1; while(!DFStack.empty()){ cur=DFStack.back(); //cout<<cur<<" "; Visited[cur]=1; if(adj[cur][IteratedAdj[cur]].first==CurParent[cur]){ IteratedAdj[cur]++; } if(IteratedAdj[cur]<adj[cur].size()-1){ //still has children DFStack.push_back(adj[cur][IteratedAdj[cur]].first); CurParent[adj[cur][IteratedAdj[cur]].first]=cur; DistFromRoot[adj[cur][IteratedAdj[cur]].first]=DistFromRoot[cur]+adj[cur][IteratedAdj[cur]].second; IteratedAdj[cur]++; }else{ //no more children. Remove from DFStack SubtreeSize[CurParent[cur]]+=SubtreeSize[cur]; DFStack.pop_back(); } } } } for(int i=0;i<CurRoots.size();i++){ pr:; //cout<<"9"; for(int k=0;k<adj[CurRoots[i]].size();k++){ if(SubtreeSize[adj[CurRoots[i]][k].first]>SubtreeSize[CurRoots[i]]/2){ CurRoots[i]=adj[CurRoots[i]][k].first; goto pr; } } } } void Solve(){ } int main(){ cin>>N>>Tar; int s,e,w; for(int i=0;i<=N+1;i++){ adj.push_back(TVector); Visited[i]=0; } for(int i=1;i<N;i++){ cin>>s>>e>>w; adj[s].push_back({e,w}); adj[e].push_back({s,w}); } DFS(); cout<<CurRoots[0]; } int best_path(int n, int k, int H[][2], int L[]){ N=n; Tar=k; for(int i=0;i<=N+1;i++){ adj.push_back(TVector); } for(int i=1;i<=N-1;i++){ adj[H[i-1][0]].push_back({H[i-1][1],L[i-1]}); adj[H[i-1][1]].push_back({H[i-1][0],L[i-1]}); } for(int i=0;i<=N;i++){ Deleted[i]=0; } Solve; if(ans==999999){ return -1; }else{ return ans; } } /* 7 100 0 1 1 0 2 1 2 3 1 2 4 1 3 5 1 2 6 1 */

Compilation message (stderr)

race.cpp: In function 'void DFS()':
race.cpp:38:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if(IteratedAdj[cur]<adj[cur].size()-1){ //still has children
      |        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
race.cpp:50:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i=0;i<CurRoots.size();i++){
      |              ~^~~~~~~~~~~~~~~~
race.cpp:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for(int k=0;k<adj[CurRoots[i]].size();k++){
      |               ~^~~~~~~~~~~~~~~~~~~~~~~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:92:2: warning: statement is a reference, not call, to function 'Solve' [-Waddress]
   92 |  Solve;
      |  ^~~~~
race.cpp:92:2: warning: statement has no effect [-Wunused-value]
/usr/bin/ld: /tmp/cc5vl1R7.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5E2Uv5.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status