-
Notifications
You must be signed in to change notification settings - Fork 0
Update main.cpp #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update main.cpp #12
Conversation
|
Ссылка на Яндекс.Контест 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; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай уже использовать либо везде векторы, либо везде простые массивы
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему это объявлено вне цикла?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Будет ли работать повторный вызов?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не будет. Потому что вектор bridges заполнен мостами с предыдущего вызова.
|
|
||
| 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
когда параметров много, можно их отдельную структуру объединить
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не так не правильно)
Ты же обычный объект получаешь, а не временный)
No description provided.