forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweakvertices.cpp
38 lines (32 loc) · 884 Bytes
/
weakvertices.cpp
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
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
while(cin >> n && n != -1) {
vector<vector<int>> v;
v.resize(n, vector<int>(n));
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cin >> v[i][j];
}
}
// For each node
for(int i = 0; i < n; i++) {
bool weak = true;
// For each of its connections
for(int j = 0; j < n; j++) {
// For each of its connections
for(int k = 0; k < n; k++) {
if(v[i][k]==1 && v[i][j]==1 && v[j][k]==1 && i!=k && i!=j && j!=k) {
weak = false;
}
}
}
if(weak) {
cout << i << " ";
}
}
cout << endl;
}
}