Advertisement
Pit_Anonim

F

Nov 25th, 2021
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main() {
  5.     int a, b;
  6.     std::cin>>a>>b;
  7.     int map[a][a];
  8.  
  9.     std::vector<std::pair<int, int>> pairs;
  10.  
  11.     int j,k;
  12.     for (int x = 0; x < b; x++) {
  13.         std::cin>>j>>k;
  14.         pairs.push_back(std::pair<int,int>(j-1,k-1));
  15.     }
  16.  
  17.     for (int x = 0; x < a; x++) {
  18.         for (int y = 0; y < a; y++) {
  19.             map[x][y] = 0;
  20.         }
  21.     }
  22.  
  23.     for (int x = 0; x < a; x++)
  24.         for (int y = 0; y < a; y++) {
  25.             for (int l = 0; l < pairs.size(); l++) {
  26.                 if (pairs[l].first == x && pairs[l].second == y) {
  27.                     map[x][y] = 1;
  28.                     map[y][x] = 1;
  29.                 }
  30.             }
  31.         }
  32.  
  33.     for (int x = 0; x < a; x++) {
  34.         for (int y = 0; y < a; y++) {
  35.             std::cout<<map[x][y]<<" ";
  36.         }
  37.         std::cout<<std::endl;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement