-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCTDL102.cpp
More file actions
40 lines (40 loc) · 785 Bytes
/
Copy pathSCTDL102.cpp
File metadata and controls
40 lines (40 loc) · 785 Bytes
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
/**
* @file SCTDL102.cpp
* @author your name (you@domain.com)
* @brief Adjacent matrix to adjacent list
* @version 0.1
* @date 2023-06-12
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, x;
cin >> n;
vector<vector<int>> a(n + 1);
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> x;
if (i > j && x == 1)
{
a[i].push_back(j);
a[j].push_back(i);
}
}
}
for (int i = 1; i <= n; i++)
{
cout << i << ": ";
for (auto j : a[i])
cout << j << " ";
cout << endl;
}
}