daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 55 in 268 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int adiacenta[101][101];
  7.  
  8. int main()
  9. {
  10.     ifstream f("graf_partial.in");
  11.  
  12.     int n;
  13.     f >> n;
  14.  
  15.     // k e nr de muchii in grafu partial
  16.     int k = 0;
  17.  
  18.     while (!f.eof())
  19.     {
  20.         int x, y;
  21.         f >> x >> y;
  22.  
  23.         adiacenta[x][y] = 1;
  24.         adiacenta[y][x] = 1;
  25.     }
  26.  
  27.     // Merg pe nodurile impare cu i
  28.     for (int i = 1; i <= n; i += 2)
  29.     {
  30.         // Merg pe nodurile pare cu j
  31.         for (int j = 2; j <= n; j += 2)
  32.         {
  33.             // Daca un nod impar cu unu impar sunt vecine/corespund unei muchii
  34.             // inseamna ca muchia aia ramane in grafu partial
  35.             if (adiacenta[i][j] == 1)
  36.             {
  37.                 k++;
  38.             }
  39.         }
  40.     }
  41.  
  42.     ofstream g("graf_partial.out");
  43.  
  44.     g << k;
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top