SHARE
TWEET

Untitled

a guest Dec 15th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #include <list>
  3. #include <stack>
  4. #include <iostream>
  5. #include <vector>
  6. #include <algorithm>
  7. using namespace std;
  8. class Graph
  9. {
  10.     int N;
  11.     int M;
  12.     bool cikel = false;
  13.     int counter = 0;
  14.     vector<vector<int>> memTable;
  15.     //Funkcije PRIVATE
  16.     void memoizedNumPadRec(int vnos, int current, int length) {
  17.         cout << "Vnos: " << vnos << endl;
  18.         cout << "Current: " << current << endl;
  19.         cout << "Length: " << length << endl;
  20.         length++;
  21.         if (length == vnos) {
  22.             counter++;
  23.             return;
  24.         }
  25.         list<int>::iterator i;
  26.         for (i = sosed[current].begin(); i != sosed[current].end(); i++) {
  27.             memoizedNumPadRec(vnos, *i, length);
  28.         }
  29.     }
  30.  
  31. public:
  32.     list<int>* sosed;
  33.     Graph(int N, int M) {
  34.         this->N = N;
  35.         sosed = new list<int>[N];
  36.         this->M = M;
  37.     }
  38.     void dodaj(int v, int v2) {
  39.         sosed[v].push_back(v2);
  40.     }
  41.     //Funkcije PUBLIC
  42.     int memoizedNumPad(int vnos) {
  43.         memoizedNumPadRec(vnos, 0, 0);
  44.         return counter;
  45.     }
  46. };
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