-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriends.cpp
More file actions
64 lines (59 loc) · 1 KB
/
Copy pathfriends.cpp
File metadata and controls
64 lines (59 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <vector>
#include <iostream>
#include <stdlib.h>
using namespace std;
vector <vector <int> >graph;
int n;
int bfs()
{
int counter = 0, c = 0;
while(c++ < n)
{
vector<int>::iterator it;
it = graph[c].begin();
vector<int>::iterator it1;
int *visited = (int*)calloc(n+1,sizeof(int));
for(it1=graph[*it].begin(); it1 < graph[*it].end();++it1)
{
vector <int>::iterator it2;
for(it2 = graph[*it1].begin(); it2 < graph[*it1].end(); ++it2)
{
printf("lol\n");
if(!visited[*it2])
{
printf("lolp\n");
visited[*it2] = 1;
counter++;
}
}
}
}
return counter;
}
int main()
{
int k;
scanf("%d",&n);
graph.resize(n*n);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
scanf("%d",&k);
if(k)
graph[i].push_back(j);
}
}
for (int i = 0; i < graph.size(); i++)
{
for (int j = 0; j < graph[i].size(); j++)
{
printf("%d ", graph[i][j]);
}
printf("\n");
}
printf("HERE\n");
printf("%d\n", bfs());
return 0;
}