-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTRR1003 1.3 DO THI.cpp
More file actions
71 lines (62 loc) · 1.26 KB
/
TRR1003 1.3 DO THI.cpp
File metadata and controls
71 lines (62 loc) · 1.26 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
65
66
67
68
69
70
71
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t, n, a[101][101];
int deg[101];
int im[101][10000];
void OpenFile() {
freopen("DT.INP", "r", stdin);
freopen("DT.OUT", "w", stdout);
}
void ReadData() {
cin >> t >> n;
for (int u = 1; u <= n; u++) {
for (int v = 1; v <= n; v++) {
cin >> a[u][v];
}
}
}
void CalcDeg() {
for (int u = 1; u <= n; u++) {
deg[u] = 0;
for (int v = 1; v <= n; v++) {
deg[u] += a[u][v];
}
}
for (int u = 1; u <= n; u++) {
cout << deg[u] << " ";
}
cout << '\n';
}
void IncMat() {
int m = 0;
for (int u = 1; u <= n - 1; u++) {
for (int v = u + 1; v <= n; v++) {
for (int t = 1; t <= a[u][v]; t++) {
m++;
im[u][m] = 1;
im[v][m] = 1;
}
}
}
cout << n << " " << m << "\n";
for (int u = 1; u <= n; u++) {
for (int v = 1; v <= m; v++) {
cout << im[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 {
IncMat();
}
return 0;
}