Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- class Graph {
- int V;
- list <int> *l;
- public:
- Graph(int V) {
- this->V=V;
- l = new list<int>[V];
- }
- void addEdge(int x,int y) {
- l[x].push_back(y);
- l[y].push_back(x);
- }
- bool checkEuclidean() {
- bool isEuclidean=true;
- for(int i=0;i<V;l++) {
- if(l[i].size()%2!=0) {
- isEuclidean=false;
- return false;
- }
- }
- return true;
- }
- };
- int main() {
- int n;
- cin>>n;
- Graph G(n);
- int i=0;
- for(int i=0;i<n;) {
- char ch;
- cin>>ch;
- // cout<<"Value of i is: "<<i;
- if(ch=='#') { continue; }
- while(ch!='#') {
- int x;
- cin>>x;
- ch = ch - '0';
- G.addEdge(i,x);
- G.addEdge(x,i);
- }
- }
- if(G.checkEuclidean()) {
- cout<<"True";
- } else {
- cout<<"False";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement