# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
110232 |
2019-05-10T09:12:16 Z |
Arturgo |
Race (IOI11_race) |
C++14 |
|
299 ms |
56904 KB |
#include "race.h"
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int INFINI = 1000 * 1000 * 1000;
int nbVilles, tailleTotale;
vector<pair<int, int>> voisins[200 * 1000];
struct Retour {
long long decProf;
int decChemin;
map<long long, int> profs;
Retour() {
decChemin = 0;
decProf = 0;
profs[0] = 0;
}
void shift(long long taille) {
decChemin++;
decProf += taille;
}
int getChemin(long long prof) {
if(profs.find(prof - decProf) == profs.end())
return INFINI;
return profs[prof - decProf] + decChemin;
}
void setChemin(long long prof, int chemin) {
profs[prof - decProf] = chemin - decChemin;
}
vector<pair<long long, int>> getProfs() {
vector<pair<long long, int>> res;
for(pair<long long, int> paire : profs) {
res.push_back({paire.first + decProf, paire.second + decChemin});
}
return res;
}
};
vector<Retour> retours;
int melChemin = INFINI;
int fusion(int a, int b) {
Retour& retA = retours[a];
Retour& retB = retours[b];
if(retA.profs.size() > retB.profs.size())
fusion(b, a);
vector<pair<long long, int>> profsA = retA.getProfs();
for(pair<int, int> paire : profsA) {
melChemin = min(melChemin, paire.second + retB.getChemin(tailleTotale - paire.first));
}
for(pair<long long, int> paire : profsA) {
retB.setChemin(paire.first, min(retB.getChemin(paire.first), paire.second));
}
return b;
}
int calcChemin(int noeud, int parent = -1) {
int id = retours.size();
retours.push_back(Retour());
for(pair<int, int> voisin : voisins[noeud]) {
if(voisin.first == parent)
continue;
int retour = calcChemin(voisin.first, noeud);
retours[retour].shift(voisin.second);
id = fusion(id, retour);
}
return id;
}
int best_path(int _nbVilles, int _tailleTotale, int adjs[][2], int tailles[]) {
nbVilles = _nbVilles;
tailleTotale = _tailleTotale;
for(int iRoute = 0;iRoute < nbVilles - 1;iRoute++) {
voisins[adjs[iRoute][0]].push_back({adjs[iRoute][1], tailles[iRoute]});
voisins[adjs[iRoute][1]].push_back({adjs[iRoute][0], tailles[iRoute]});
}
calcChemin(0);
if(melChemin == INFINI)
return -1;
return melChemin;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
5120 KB |
Output is correct |
2 |
Correct |
8 ms |
5120 KB |
Output is correct |
3 |
Correct |
6 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5248 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
7 ms |
5120 KB |
Output is correct |
7 |
Correct |
10 ms |
5120 KB |
Output is correct |
8 |
Correct |
6 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
8 ms |
5120 KB |
Output is correct |
11 |
Correct |
6 ms |
5120 KB |
Output is correct |
12 |
Correct |
6 ms |
5120 KB |
Output is correct |
13 |
Correct |
7 ms |
5088 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
7 ms |
5120 KB |
Output is correct |
18 |
Correct |
8 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
5120 KB |
Output is correct |
2 |
Correct |
8 ms |
5120 KB |
Output is correct |
3 |
Correct |
6 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5248 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
7 ms |
5120 KB |
Output is correct |
7 |
Correct |
10 ms |
5120 KB |
Output is correct |
8 |
Correct |
6 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
8 ms |
5120 KB |
Output is correct |
11 |
Correct |
6 ms |
5120 KB |
Output is correct |
12 |
Correct |
6 ms |
5120 KB |
Output is correct |
13 |
Correct |
7 ms |
5088 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
7 ms |
5120 KB |
Output is correct |
18 |
Correct |
8 ms |
5120 KB |
Output is correct |
19 |
Correct |
7 ms |
5120 KB |
Output is correct |
20 |
Correct |
8 ms |
5120 KB |
Output is correct |
21 |
Correct |
14 ms |
6400 KB |
Output is correct |
22 |
Correct |
10 ms |
6016 KB |
Output is correct |
23 |
Correct |
16 ms |
6912 KB |
Output is correct |
24 |
Correct |
15 ms |
7424 KB |
Output is correct |
25 |
Correct |
14 ms |
7548 KB |
Output is correct |
26 |
Correct |
12 ms |
6912 KB |
Output is correct |
27 |
Correct |
8 ms |
5376 KB |
Output is correct |
28 |
Incorrect |
18 ms |
7424 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
5120 KB |
Output is correct |
2 |
Correct |
8 ms |
5120 KB |
Output is correct |
3 |
Correct |
6 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5248 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
7 ms |
5120 KB |
Output is correct |
7 |
Correct |
10 ms |
5120 KB |
Output is correct |
8 |
Correct |
6 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
8 ms |
5120 KB |
Output is correct |
11 |
Correct |
6 ms |
5120 KB |
Output is correct |
12 |
Correct |
6 ms |
5120 KB |
Output is correct |
13 |
Correct |
7 ms |
5088 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
7 ms |
5120 KB |
Output is correct |
18 |
Correct |
8 ms |
5120 KB |
Output is correct |
19 |
Incorrect |
299 ms |
56904 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
5120 KB |
Output is correct |
2 |
Correct |
8 ms |
5120 KB |
Output is correct |
3 |
Correct |
6 ms |
5120 KB |
Output is correct |
4 |
Correct |
8 ms |
5248 KB |
Output is correct |
5 |
Correct |
8 ms |
5120 KB |
Output is correct |
6 |
Correct |
7 ms |
5120 KB |
Output is correct |
7 |
Correct |
10 ms |
5120 KB |
Output is correct |
8 |
Correct |
6 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
8 ms |
5120 KB |
Output is correct |
11 |
Correct |
6 ms |
5120 KB |
Output is correct |
12 |
Correct |
6 ms |
5120 KB |
Output is correct |
13 |
Correct |
7 ms |
5088 KB |
Output is correct |
14 |
Correct |
7 ms |
5120 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5120 KB |
Output is correct |
17 |
Correct |
7 ms |
5120 KB |
Output is correct |
18 |
Correct |
8 ms |
5120 KB |
Output is correct |
19 |
Correct |
7 ms |
5120 KB |
Output is correct |
20 |
Correct |
8 ms |
5120 KB |
Output is correct |
21 |
Correct |
14 ms |
6400 KB |
Output is correct |
22 |
Correct |
10 ms |
6016 KB |
Output is correct |
23 |
Correct |
16 ms |
6912 KB |
Output is correct |
24 |
Correct |
15 ms |
7424 KB |
Output is correct |
25 |
Correct |
14 ms |
7548 KB |
Output is correct |
26 |
Correct |
12 ms |
6912 KB |
Output is correct |
27 |
Correct |
8 ms |
5376 KB |
Output is correct |
28 |
Incorrect |
18 ms |
7424 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |