-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTRR1006 1.6 DO THI.cpp
More file actions
64 lines (58 loc) · 1.09 KB
/
TRR1006 1.6 DO THI.cpp
File metadata and controls
64 lines (58 loc) · 1.09 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t, n, m, sp[105], ep[5000];
int deg[101];
int a[101][10000];
void OpenFile() {
freopen("DT.INP", "r", stdin);
freopen("DT.OUT", "w", stdout);
}
void ReadData() {
cin >> t >> n >> m;
for(int i = 1; i <= m; i++){
cin >> sp[i] >> ep[i];
}
}
void CalcDeg() {
int u, v, t;
for(u = 1; u <= n; u++){
deg[u] = 0;
}
for(t = 1; t <= m; t++){
u = sp[t];
v = ep[t];
deg[u]++;
deg[v]++;
}
for(u = 1; u <= n; u++){
cout << deg[u] << " ";
}
}
void AdjMat(){
cout << n << " " << m << "\n";
int u,v,t;
for(t = 1; t <= m; t++){
u = sp[t]; a[u][t] = 1;
v = ep[t]; a[v][t] = 1;
}
for(u = 1; u <= n; u++){
for(v = 1; v <= m; v++){
cout << a[u][v] << " ";
}
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
OpenFile();
ReadData();
if (t == 1) {
CalcDeg();
} else {
AdjMat();
}
return 0;
}