Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- using namespace std;
- #define MAXN 1000;
- #define MAXM 1500;
- int main() {
- vector<vector<int>> G;
- int res = 0;
- int gradove;
- int putishta;
- cin >> gradove;
- cin >> putishta;
- while (putishta > 0) {
- vector<int> g;
- int a;
- int b;
- cin >> a;
- cin >> b;
- g.push_back(a);
- g.push_back(b);
- G.push_back(g);
- putishta--;
- }
- for (int i = 0; i < G.size(); i++) {
- if (G[i][0] != 0) {
- int resultCount = 1;
- queue<int> que;
- que.push(G[i][0]);
- G[i][0] = 0;
- que.push(G[i][1]);
- G[i][1] = 0;
- while (que.size() > 0) {
- for (int j = i + 1; j < G.size(); j++) {
- if (G[j][0] == que.front()) {
- resultCount++;
- que.push(G[j][1]);
- G[j][0] = 0;
- G[j][1] = 0;
- }
- }
- for (int j = i + 1; j < G.size(); j++) {
- if (G[j][1] == que.front()) {
- resultCount++;
- que.push(G[j][0]);
- G[j][0] = 0;
- G[j][1] = 0;
- }
- }
- que.pop();
- }
- if (res < resultCount) {
- res = resultCount;
- }
- }
- }
- cout << res;
- system("Pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement