Submission #432093

#TimeUsernameProblemLanguageResultExecution timeMemory
432093REALITYNBRail (IOI14_rail)C++17
30 / 100
86 ms504 KiB
#include <bits/stdc++.h> #include "rail.h" using namespace std; void findLocation(int n ,int first , int* loc , int* stype){ loc[0]=first ; stype[0]=1; if(n==1) return ; vector<int> a(n) ; for(int i=0;i<n;i++) a[i]=getDistance(i,0) ; int mn = 1e9; for(int i=1;i<n;i++) mn=min(mn,a[i]) ; int second ; for(int i=1;i<n;i++) if(mn==a[i]) second=i; vector<int> b(n) ; stype[second]=2,loc[second]=first+mn; for(int i=0;i<n;i++) b[i]=getDistance(i,second); for(int i=0;i<n;i++){ if(i==second||i==0) continue ; if(a[i]>b[i]){ stype[i]=1; loc[i]=loc[second]-b[i] ; } else{ stype[i]=2; loc[i]=loc[0]+a[i]; } } return ; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:15:11: warning: 'second' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |     stype[second]=2,loc[second]=first+mn;
      |           ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...