Skip to content

Conversation

@kindofman
Copy link
Owner

No description provided.

@kindofman kindofman requested a review from ylyubimov December 7, 2019 21:41
@kindofman
Copy link
Owner Author

Ссылка на Яндекс.Контест https://contest.yandex.ru/contest/15957/run-report/28447061/

12/main.cpp Outdated
const int V;
void add_edge( int v, int w );
vector<int> get_bridges();
vector<int> bridges;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Странно делать все эти поля публичными - это раз.
А потом давай не будем класс засорять ненужными ему полями. Создавать доп.массивы нужно в алгоритме, потом удалять

12/main.cpp Outdated
}

vector<int> Graph::get_bridges() {
bool *visited = new bool[V];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай уже использовать либо везде векторы, либо везде простые массивы

Copy link
Owner Author

@kindofman kindofman Dec 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

12/main.cpp Outdated
static int time = 0;
visited[u] = true;
disc[u] = low[u] = ++time;
list<int>::iterator i;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему это объявлено вне цикла?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Убрал

};
const int V;
void add_edge( int v, int w );
vector<int> get_bridges();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Будет ли работать повторный вызов?

Copy link
Owner Author

@kindofman kindofman Dec 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не будет. Потому что вектор bridges заполнен мостами с предыдущего вызова.

@kindofman kindofman requested a review from ylyubimov December 15, 2019 09:01

void Graph::get_bridges_util(int u, bool* visited, int* disc,
int* low, int* parent) {
void Graph::get_bridges_util(int u, vector<bool>& visited, vector<int>& disc,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

когда параметров много, можно их отдельную структуру объединить

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BridgesContext

g.add_edge(v-1, w-1);
}
vector<int> bridges = g.get_bridges();
vector<int>&& bridges = g.get_bridges();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не так не правильно)
Ты же обычный объект получаешь, а не временный)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants