Advertisement
Singasking

Untitled

Sep 26th, 2022
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. class Graph {
  6. int V;
  7. list <int> *l;
  8. public:
  9. Graph(int V) {
  10. this->V=V;
  11. l = new list<int>[V];
  12.  
  13. }
  14. void addEdge(int x,int y) {
  15. l[x].push_back(y);
  16. l[y].push_back(x);
  17.  
  18. }
  19.  
  20. bool checkEuclidean() {
  21. bool isEuclidean=true;
  22. for(int i=0;i<V;l++) {
  23. if(l[i].size()%2!=0) {
  24. isEuclidean=false;
  25. return false;
  26. }
  27. }
  28.  
  29. return true;
  30. }
  31. };
  32. int main() {
  33. int n;
  34. cin>>n;
  35. Graph G(n);
  36. int i=0;
  37. for(int i=0;i<n;) {
  38. char ch;
  39. cin>>ch;
  40. // cout<<"Value of i is: "<<i;
  41. if(ch=='#') { continue; }
  42.  
  43. while(ch!='#') {
  44. int x;
  45. cin>>x;
  46. ch = ch - '0';
  47. G.addEdge(i,x);
  48. G.addEdge(x,i);
  49.  
  50. }
  51. }
  52.  
  53. if(G.checkEuclidean()) {
  54. cout<<"True";
  55. } else {
  56. cout<<"False";
  57. }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement