Cod sursa(job #882280)

Utilizator trifan_gabrielaTrifan Gabriela trifan_gabriela Data 18 februarie 2013 23:34:40
Problema Ciclu Eulerian Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.91 kb
#include<fstream>

using namespace std;
 
ifstream fin("eulerian.in");
ofstream fout("eulerian.out");
 
typedef struct nod
{
    int inc,i;
    nod *next;
} nod;

typedef nod *graf[100010];
graf G;
 
int n, m, v[10001], viz[10001], A[10001], x;
 
void citire()
{
    fin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x, y;
        fin>>x>>y;
        nod *p=new nod;
		p->inc=x;
		p->i++;
		p->next=G[y];
		G[y]=p;
        nod *q=new nod;
		q->inc=y;
		q->i++;
		q->next=G[x];
		G[x]=q;
    }
}
 
int main()
{
    citire();
    if(x<m)
        fout<<-1<<'\n';
    else
    {
        int ok=1;
        for(int i=1;i<=n && ok;i++)
            if(!viz[i])
            {
                fout<<-1;
                ok=0;
            }
        if(ok)
            for(int i=1;i<=m;i++)
                fout<<A[i]<<' ';
    }
    fout<<'\n';
    fout.close();
    return 0;
}