-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCTDL103.cpp
45 lines (45 loc) · 937 Bytes
/
SCTDL103.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
39
40
41
42
43
44
45
/**
* @file SCTDL103.cpp
* @author long ([email protected])
* @brief Transform adjacent list to adjacent matrix
* @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;
cin >> n;
string s;
vector<vector<int>> a(n + 1, vector<int>(n + 1, 0));
cin.ignore();
for (int i = 1; i <= n; i++)
{
getline(cin, s);
s += ' ';
int k = 0;
for (int j = 0; j < s.size(); j++)
{
if (s[j] >= '0' && s[j] <= '9')
k = k * 10 + s[j] - '0';
else
{
a[i][k] = a[k][i] = 1;
k = 0;
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
cout << a[i][j] << " ";
cout << endl;
}
}