# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426021 | oscar1f | Race (IOI11_race) | C++17 | 1 ms | 716 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
const int TAILLE_MAX=1000;
int deb;
vector<pair<int,int>> adja[TAILLE_MAX];
int dist[TAILLE_MAX][TAILLE_MAX][2];
void DFS(int pos,int distKm,int distArete) {
if (dist[deb][pos][0]==-1) {
dist[deb][pos][0]=distKm;
dist[deb][pos][1]=distArete;
for (int ivois=0;ivois<adja[pos].size();ivois++) {
DFS(adja[pos][ivois].first,distKm+adja[pos][ivois].second,distArete+1);
}
}
}
int best_path(int N, int K, int H[][2], int L[]) {
int record=-1;
for (int i=0;i<N-1;i++) {
adja[H[i][0]].push_back(make_pair(H[i][1],L[i]));
adja[H[i][1]].push_back(make_pair(H[i][0],L[i]));
}
for (int i=0;i<N;i++) {
for (int j=0;j<N;j++) {
dist[i][j][0]=-1;
}
}
for (int i=0;i<N;i++) {
deb=i;
DFS(i,0,0);
}
for (int i=0;i<N;i++) {
for (int j=0;j<N;j++) {
if (dist[i][j][0]==K) {
record=min(record,dist[i][j][1]);
}
}
}
return record;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |