nihonium
/
mipt_clang
Archived
1
0
Fork 0
remotes/private/master
nihonium 3 years ago
parent eeffd774de
commit e7c8e83ce0

@ -1,2 +1,5 @@
# mipt_clang # MIPT C
Код из лекций Бабичева по алгоритмам и структурам данных.
Несколько решенных задач для контестов с Ejudge и горка всякой мелочевки.

@ -1,6 +1,26 @@
#include "queue.c" #include "queue.c"
#include "graph.c" #include "graph.c"
void graph_bfs(graph *t, int s, int *d) {
color *c = (color *)calloc(sizeof(color),t->N);
for (int i = 0; i < t->N; i++) d[i] = -1;
queue *q = queue_new(t->N*t->N);
queue_enqueue(q, s);
d[s] = 0; c[s] = GREY;
while (!queue_empty(q)) {
int u = queue_dequeue(q);
for (int z = 0; z < t->N; z++) {
if (t->neibs[u*t->N+z] == 0 || c[z] != WHITE) continue;
d[z] = d[u] + 1;
c[z] = GREY;
queue_enqueue(q,z);
}
c[u] = BLACKl
}
queue_delete(q);
free(c);
}
int main() { int main() {
queue *q = queue_new(5); queue *q = queue_new(5);
} }