Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void print(vector<vector<int>> v) {
- cout << endl;
- for (int i = 0; i < v.size(); i ++) {
- for (int j = 0; j < v[i].size(); j ++)
- cout << v[i][j] << " ";
- cout << endl;
- }
- }
- int main() {
- int n, m;
- cin >> n >> m;
- vector<vector<int>> a;
- for (int i = 0; i < m; i ++) {
- a.push_back(vector<int>(3));
- cin >> a[i][0] >> a[i][1] >> a[i][2];
- }
- vector<vector<int>> b;
- for (int i = 0; i < n; i ++) {
- b.push_back(vector<int>(m));
- }
- for (int i = 0; i < m; i ++) {
- b[a[i][0]][i] = 1;
- b[a[i][1]][i] = 1;
- }
- vector<vector<int>> c;
- for (int i = 0; i < n; i ++)
- c.push_back(vector<int>(n));
- for (int i = 0; i < m; i ++) {
- c[a[i][0]][a[i][1]] = a[i][2];
- c[a[i][1]][a[i][0]] = a[i][2];
- }
- vector<vector<int>> d;
- for (int i = 0; i < n; i ++)
- d.push_back(vector<int>());
- for (int i = 0; i < m; i ++) {
- d[a[i][0]].push_back(a[i][1]);
- d[a[i][1]].push_back(a[i][0]);
- }
- print(a);
- print(b);
- print(c);
- print(d);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement