Skip to content

Update main.cpp#11

Open
kindofman wants to merge 4 commits into
masterfrom
kindofman-patch-11
Open

Update main.cpp#11
kindofman wants to merge 4 commits into
masterfrom
kindofman-patch-11

Conversation

@kindofman
Copy link
Copy Markdown
Owner

No description provided.

@kindofman kindofman requested a review from ylyubimov December 1, 2019 17:30
Copy link
Copy Markdown
Collaborator

@ylyubimov ylyubimov left a comment

Choose a reason for hiding this comment

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

В целом классно будет, если ты напишешь какое-то подобие структуры графа.
template <class TVertex, class TEdge>
class Graph {
public:
size_t VerticiesCount() const;
const TVertex& Get(int index) const;
std::vector<std::pair<int, TEdge>> GetNextEdges(int from) const;
std::vector<std::pair<int, TEdge>> GetPrevEdges(int to) const;
};
И алгоритмы уже будешь писать для работы с ним
Подумай не в сторону решения задач, а в сторону создания библиотеки графов)) Раз ты опережаешь всех

Comment thread 11-2/main.cpp Outdated
int main() {
int v_, n;
std::cin >> v_ >> n;
vector <int>* adj = new vector <int>[v_];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Пускай это будет уже вектор векторов)

@ylyubimov
Copy link
Copy Markdown
Collaborator

Ссылку на контест лучше в комментарии к Пулл реквесту))

@kindofman
Copy link
Copy Markdown
Owner Author

Сказано - сделано:)

@kindofman kindofman requested a review from ylyubimov December 8, 2019 07:33
Comment thread 11-2/main.cpp Outdated
public:
Graph(int v): v(v) { adj.assign(v, {}); };
void BFS( vector<vector <int> > adj, int src, int dist[], int* paths, int n );
int find_shortest_paths( int s, int n, int w );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Не забывай константность методов

Comment thread 11-2/main.cpp Outdated
class Graph {
public:
Graph(int v): v(v) { adj.assign(v, {}); };
void BFS( vector<vector <int> > adj, int src, int dist[], int* paths, int n );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Теперь BFS это метод у него и так есть adj

Comment thread 11-2/main.cpp Outdated
};

void Graph::BFS( vector<vector <int> > adj, int src, int dist[], int* paths, int n ) {
bool* visited = new bool[n];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Лучше вектора использовать

Comment thread 11-2/main.cpp Outdated
}

int Graph::find_shortest_paths( int s, int n, int w ) {
int dist[n];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

std::vector(n, INT_MAX)

@kindofman
Copy link
Copy Markdown
Owner Author

Постарался устранить замечания.

@kindofman kindofman requested a review from ylyubimov December 14, 2019 09:28
@kindofman
Copy link
Copy Markdown
Owner Author

Еще раз закоммитил. Предыдущий раз криво скопировал.

Comment thread 11-2/main.cpp
#include <assert.h>
#include <list>
#include <vector>
#define INT_MAX 2147483647
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Кажется, есть стандартный INT_MAX

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

У меня в IDE работает без макроса. Но в Яндекс.Контест без этого не компилируется.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

понятно. Нужно numeric_limits использовать)

@kindofman kindofman requested a review from ylyubimov December 29, 2019 05:52
Comment thread 11-2/main.cpp
#include <assert.h>
#include <list>
#include <vector>
#define INT_MAX 2147483647
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

понятно. Нужно numeric_limits использовать)

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