# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
110243 |
2019-05-10T09:39:37 Z |
Arturgo |
Race (IOI11_race) |
C++14 |
|
655 ms |
105224 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()) {
return fusion(b, a);
}
vector<pair<long long, int>> profsA = retA.getProfs();
for(pair<long long, 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 |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
5064 KB |
Output is correct |
4 |
Correct |
6 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
9 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
4992 KB |
Output is correct |
8 |
Correct |
9 ms |
4992 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
6 ms |
4864 KB |
Output is correct |
14 |
Correct |
8 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
7 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
5064 KB |
Output is correct |
4 |
Correct |
6 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
9 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
4992 KB |
Output is correct |
8 |
Correct |
9 ms |
4992 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
6 ms |
4864 KB |
Output is correct |
14 |
Correct |
8 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
7 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
19 |
Correct |
9 ms |
4992 KB |
Output is correct |
20 |
Correct |
6 ms |
4992 KB |
Output is correct |
21 |
Correct |
8 ms |
5376 KB |
Output is correct |
22 |
Correct |
9 ms |
5376 KB |
Output is correct |
23 |
Correct |
11 ms |
5376 KB |
Output is correct |
24 |
Correct |
7 ms |
5376 KB |
Output is correct |
25 |
Correct |
7 ms |
5376 KB |
Output is correct |
26 |
Correct |
8 ms |
5348 KB |
Output is correct |
27 |
Correct |
7 ms |
5248 KB |
Output is correct |
28 |
Correct |
8 ms |
5376 KB |
Output is correct |
29 |
Correct |
8 ms |
5420 KB |
Output is correct |
30 |
Correct |
8 ms |
5376 KB |
Output is correct |
31 |
Correct |
8 ms |
5376 KB |
Output is correct |
32 |
Correct |
8 ms |
5376 KB |
Output is correct |
33 |
Correct |
9 ms |
5376 KB |
Output is correct |
34 |
Correct |
7 ms |
5248 KB |
Output is correct |
35 |
Correct |
10 ms |
5292 KB |
Output is correct |
36 |
Correct |
9 ms |
5248 KB |
Output is correct |
37 |
Correct |
8 ms |
5248 KB |
Output is correct |
38 |
Correct |
14 ms |
5340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
5064 KB |
Output is correct |
4 |
Correct |
6 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
9 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
4992 KB |
Output is correct |
8 |
Correct |
9 ms |
4992 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
6 ms |
4864 KB |
Output is correct |
14 |
Correct |
8 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
7 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
19 |
Correct |
214 ms |
31976 KB |
Output is correct |
20 |
Correct |
168 ms |
33216 KB |
Output is correct |
21 |
Correct |
180 ms |
32972 KB |
Output is correct |
22 |
Correct |
194 ms |
32664 KB |
Output is correct |
23 |
Correct |
272 ms |
45384 KB |
Output is correct |
24 |
Correct |
197 ms |
36120 KB |
Output is correct |
25 |
Correct |
167 ms |
32224 KB |
Output is correct |
26 |
Correct |
112 ms |
38856 KB |
Output is correct |
27 |
Correct |
346 ms |
49360 KB |
Output is correct |
28 |
Correct |
456 ms |
85448 KB |
Output is correct |
29 |
Correct |
471 ms |
84276 KB |
Output is correct |
30 |
Correct |
320 ms |
49400 KB |
Output is correct |
31 |
Correct |
294 ms |
49340 KB |
Output is correct |
32 |
Correct |
338 ms |
49604 KB |
Output is correct |
33 |
Correct |
291 ms |
54204 KB |
Output is correct |
34 |
Correct |
456 ms |
87100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4992 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
7 ms |
5064 KB |
Output is correct |
4 |
Correct |
6 ms |
4992 KB |
Output is correct |
5 |
Correct |
7 ms |
4992 KB |
Output is correct |
6 |
Correct |
9 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
4992 KB |
Output is correct |
8 |
Correct |
9 ms |
4992 KB |
Output is correct |
9 |
Correct |
7 ms |
4992 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
6 ms |
4992 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
6 ms |
4864 KB |
Output is correct |
14 |
Correct |
8 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
4992 KB |
Output is correct |
17 |
Correct |
7 ms |
4992 KB |
Output is correct |
18 |
Correct |
7 ms |
4992 KB |
Output is correct |
19 |
Correct |
9 ms |
4992 KB |
Output is correct |
20 |
Correct |
6 ms |
4992 KB |
Output is correct |
21 |
Correct |
8 ms |
5376 KB |
Output is correct |
22 |
Correct |
9 ms |
5376 KB |
Output is correct |
23 |
Correct |
11 ms |
5376 KB |
Output is correct |
24 |
Correct |
7 ms |
5376 KB |
Output is correct |
25 |
Correct |
7 ms |
5376 KB |
Output is correct |
26 |
Correct |
8 ms |
5348 KB |
Output is correct |
27 |
Correct |
7 ms |
5248 KB |
Output is correct |
28 |
Correct |
8 ms |
5376 KB |
Output is correct |
29 |
Correct |
8 ms |
5420 KB |
Output is correct |
30 |
Correct |
8 ms |
5376 KB |
Output is correct |
31 |
Correct |
8 ms |
5376 KB |
Output is correct |
32 |
Correct |
8 ms |
5376 KB |
Output is correct |
33 |
Correct |
9 ms |
5376 KB |
Output is correct |
34 |
Correct |
7 ms |
5248 KB |
Output is correct |
35 |
Correct |
10 ms |
5292 KB |
Output is correct |
36 |
Correct |
9 ms |
5248 KB |
Output is correct |
37 |
Correct |
8 ms |
5248 KB |
Output is correct |
38 |
Correct |
14 ms |
5340 KB |
Output is correct |
39 |
Correct |
214 ms |
31976 KB |
Output is correct |
40 |
Correct |
168 ms |
33216 KB |
Output is correct |
41 |
Correct |
180 ms |
32972 KB |
Output is correct |
42 |
Correct |
194 ms |
32664 KB |
Output is correct |
43 |
Correct |
272 ms |
45384 KB |
Output is correct |
44 |
Correct |
197 ms |
36120 KB |
Output is correct |
45 |
Correct |
167 ms |
32224 KB |
Output is correct |
46 |
Correct |
112 ms |
38856 KB |
Output is correct |
47 |
Correct |
346 ms |
49360 KB |
Output is correct |
48 |
Correct |
456 ms |
85448 KB |
Output is correct |
49 |
Correct |
471 ms |
84276 KB |
Output is correct |
50 |
Correct |
320 ms |
49400 KB |
Output is correct |
51 |
Correct |
294 ms |
49340 KB |
Output is correct |
52 |
Correct |
338 ms |
49604 KB |
Output is correct |
53 |
Correct |
291 ms |
54204 KB |
Output is correct |
54 |
Correct |
456 ms |
87100 KB |
Output is correct |
55 |
Correct |
34 ms |
8812 KB |
Output is correct |
56 |
Correct |
21 ms |
7672 KB |
Output is correct |
57 |
Correct |
153 ms |
30644 KB |
Output is correct |
58 |
Correct |
99 ms |
23640 KB |
Output is correct |
59 |
Correct |
158 ms |
45132 KB |
Output is correct |
60 |
Correct |
408 ms |
84512 KB |
Output is correct |
61 |
Correct |
389 ms |
52996 KB |
Output is correct |
62 |
Correct |
370 ms |
49468 KB |
Output is correct |
63 |
Correct |
368 ms |
49744 KB |
Output is correct |
64 |
Correct |
626 ms |
105224 KB |
Output is correct |
65 |
Correct |
621 ms |
103332 KB |
Output is correct |
66 |
Correct |
459 ms |
81856 KB |
Output is correct |
67 |
Correct |
258 ms |
43972 KB |
Output is correct |
68 |
Correct |
521 ms |
66304 KB |
Output is correct |
69 |
Correct |
655 ms |
71444 KB |
Output is correct |
70 |
Correct |
595 ms |
63676 KB |
Output is correct |