Advertisement
Josif_tepe

Untitled

Feb 26th, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n,k;
  8.     cin>>n>>k;
  9.     int m[n][n];
  10.     int a,b;
  11.     int l=0;
  12.     for(int i=0;i<n;i++)
  13.     {
  14.         for(int j=0;j<n;j++)
  15.         {
  16.             m[i][j]=0;
  17.         }
  18.     }
  19.     for(int i=0;i<k;i++)
  20.     {
  21.         cin>>a>>b;
  22.         m[a-1][b-1]=1;
  23.     }
  24.     for(int i=0;i<n;i++)
  25.     {
  26.         for(int j=0;j<n;j++)
  27.         {
  28.             if(m[i][j]==1 && m[j][i]!=1)
  29.             {
  30.                 l++;
  31.             }
  32.         }
  33.     }
  34.     cout<<l;
  35.     return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement