Advertisement
Pit_Anonim

O

Nov 25th, 2021
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int n, m;
  8.     cin>>n>>m;
  9.  
  10.     std::pair<int, int> a[m];
  11.  
  12.     for (int i = 0; i < m; i++) {
  13.         cin>>a[i].first>>a[i].second;
  14.         a[i].first--;
  15.         a[i].second--;
  16.     }
  17.  
  18.     vector<int> h;
  19.  
  20.     bool r = false;
  21.  
  22.     int matrix[n][n];
  23.  
  24.     for (int x = 0; x < n; x++) {
  25.         for (int y = 0; y < n; y++) {
  26.             for (int i = 0; i < m; i++) {
  27.                 if (a[i].first == x && a[i].second == y) {
  28.                     r = true;
  29.                     matrix[x][y] = 1;
  30.                     break;
  31.                 }
  32.             }
  33.  
  34.             if (!r) matrix[x][y] = 0;
  35.             r = false;
  36.         }
  37.     }
  38.  
  39.     int g = 0;
  40.     int j1 = 0;
  41.     for (int x = 0; x < n; x++) {
  42.         for (int y = 0; y < n; y++) {
  43.             if (matrix[x][y]) {
  44.                 g++;
  45.             }
  46.         }
  47.  
  48.         for (int u = 0; u < n; u++) {
  49.             if (matrix[u][x]) {
  50.                 j1++;
  51.             }
  52.         }
  53.  
  54.         cout<<j1<<endl<<g<<endl;
  55.         g=0;
  56.         j1=0;
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement