Submission #1016515

#TimeUsernameProblemLanguageResultExecution timeMemory
1016515simona1230Rail (IOI14_rail)C++17
30 / 100
187 ms98388 KiB
#include<bits/stdc++.h> #include "rail.h" using namespace std; int l[5001],t[5001]; int d[5001][5001]; int minn[5001],vr[5001]; int n; void rec(int v) { for(int i=0; i<n; i++) { if(t[i]||vr[i]!=v)continue; if(t[v]==1) { l[i]=l[v]+d[v][i]; t[i]=2; } else { l[i]=l[v]-d[v][i]; t[i]=1; } rec(i); } } void findLocation(int N, int first, int location[], int stype[]) { n=N; for(int i=0; i<N; i++) minn[i]=1e9; for(int i=0; i<N; i++) { for(int j=i+1; j<N; j++) { d[i][j]=d[j][i]=getDistance(i,j); //cout<<i<<" "<<j<<" "<<d[i][j]<<endl; if(d[i][j]<minn[i]) { //cout<<j<<endl; minn[i]=d[i][j]; vr[i]=j; } if(d[i][j]<minn[j]) { minn[j]=d[i][j]; vr[j]=i; } } } l[0]=first; t[0]=1; rec(0); for(int i=0; i<n; i++) { location[i]=l[i],stype[i]=t[i]; //cout<<i<<" "<<vr[i]<<" "<<minn[i]<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...