• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 25th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <vector>
3. #include <list>
4. #include <utility>
5. #include <algorithm>
6. using namespace std;
7. int n=9;
8. vector<int> d={1, 1, 2, 3, 0, 5, 1, 1, 4};
9. typedef vector<list<int>> graf;
10. int main()
11. {
12.
13.     graf g(n);
14.     vector<int> perm(n);//indicii varfurilor
15.     for(int i=0;i<n;i++)
16.         perm[i]=i;
17.     int maxim=-1;
18.     for(int i=0;i<n;i++)
19.         {
20.     //ordonam subsecvanta intre i si n-1
21.
22.         for(int j=i;j<n-1;j++)
23.            {
24.                if(d[j]>maxim)
25.             maxim=d[j];
26.             }
27.             }
29. for(int j=i;j<n;j++)
31. int c=i;
32.     for(int k=maxim;k>=0;k--)
33.     {
35.     {
36.         d[c]=k;
37.         perm[c]=*it;
38.         c++;
39.     }
40.     }
41. //sa consideram varful in pozitia i;de grad maxim
42.     if(i+d[i]>=n||d[i+d[i]]==0)
43.     {
44.     cout<<" NU este o secvanta grafica"<<endl;
45.     break;
46.     }
47.     else
48.     {
49.     for(int j=i+1;j<=i+d[i];j++)
50.     {
51.         g(perm[i]push.back(perm[j]));
52.         g(perm[j]push.back(perm[i]));
53.         d[j]--;
54.     }
55.     }
56.
57.     return 0;
58.     }
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.
Not a member of Pastebin yet?