-
Notifications
You must be signed in to change notification settings - Fork 0
/
algo.cpp
109 lines (97 loc) · 2.7 KB
/
algo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
** GOOGLE PROJECT, 2021
** GoogleHashcode2021
** File description:
** algo
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include "class.hpp"
void lengthcar(City *city)
{
for(int n = 0; n < city->_nbCars; n++)
for(int i = cars[n]._nbStreet - 1; i > 0; i--)
cars[n]._lengthStreet += cars[i].route.length;
}
void set_redlight(route *routes){
for(int i = 0; i < nbcars; i++) {
if (cars[i].len_routes < tps_simulation + 1)
for (int n = 0, t = 0; n < nb routes; n++) {
if (routes[n].temps == NULL)
route[n].temps = (t % 2) + 1;
t += route[n].length
}
}
}
int count_notempty(intersection inter)
{
int nb;
for(int i = 0; i < inter.nbstreet; i++)
if (inter.rue[i].temps != NULL)
nb++;
return nb;
}
void print_results(intersection *intersections){
int nb = 0;
for(int i = 0; i < nb_intersections; i++){
for (int n = 0; n < intersections[i].nb; n++)
if (intersection[i].rue[n].time != NULL)
nb++;
}
std:cout << nb;
std:cout << intersection.nb << count_notempty(intersections);
for(int i = 0; i < nb_intersections; i++)
std:cout << intersections.rue.name << intersections.rue.temps;
}route[n].temps = (t % 2) + 1;
t += route[n].length
}
}
}
int count_notempty(intersection inter)
{
int nb;
for(int i = 0; i < inter.nbstreet; i++)
if (inter.rue[i].temps != NULL)
nb++;
return nb;
}
void print_results(intersection *intersections)
{
int nb = 0;
for(int i = 0; i < nb_intersections; i++){
for (int n = 0; n < intersections[i].nb; n++)
if (intersection[i].rue[n].time != NULL)
nb++;
}
std:cout << nb;
std:cout << intersection.nb << count_notempty(intersections);
for(int i = 0; i < nb_intersections; i++)
std:cout << intersections.rue.name << intersections.rue.temps;
}route[n].temps = (t % 2) + 1;
t += route[n].length
}
}
}
int count_notempty(intersection inter)
{
int nb;
for(int i = 0; i < inter.nbstreet; i++)
if (inter.rue[i].temps != NULL)
nb++;
return nb;
}
void print_results(intersection *intersections)
{
int nb = 0;
for(int i = 0; i < nb_intersections; i++){
for (int n = 0; n < intersections[i].nb; n++)
if (intersection[i].rue[n].time != NULL)
nb++;
}
std:cout << nb;
std:cout << intersection.nb << count_notempty(intersections);
for(int i = 0; i < nb_intersections; i++)
std:cout << intersections.rue.name << intersections.rue.temps;
}