ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1022. Genealogical Tree

drive me mad!!why Compilation error !!??
Posted by bottles 13 Nov 2007 19:49
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
struct list{
       int num[100];
};
struct graph{
       int used;
       int degree;
       int parent;
       struct list* p;
};
void initialize(struct graph* g,short int n){
     for(int i=1;i<n+1;i++){
               g[i].used=0;
               g[i].degree=0;
               g[i].parent=0;
               struct list* p=new list;
               int number;
               g[i].p=p;
               do{
                   scanf("%d",&number);
                   if(number!=0){
                   g[i].p->num[g[i].degree++]=number;
                   }
               }while(number!=0);
     }
}
int findzero(struct graph* g,int n)
{
      for(int i=1;i<n+1;i++)
          if(g[i].parent==0&&(!g[i].used)){
              g[i].used=1;
              return i;
              }
}
void topsort(struct graph* g,int n)
{
     for(int i=1;i<n+1;i++){
               int v=findzero(g,n);

               printf("%d ",v);
               for(int j=0;j<g[v].degree;j++){
                   g[g[v].p->num[j]].parent--;
               }
     }
     printf("\n");
 }
void calparent(struct graph* g,int n)
{
     for(int i=1;i<n+1;i++)
         for(int j=0;j<g[i].degree;j++)
             g[g[i].p->num[j]].parent++;
 }
int main()
{
    int n;
    scanf("%d",&n);
    struct graph g[n+1];
    initialize(g,n);
    calparent(g,n);
    topsort(g,n);

    return 0;
}
----------------------------
i got right in my own ide, but in ural it said compilation error!!__why?????
Re: drive me mad!!why Compilation error !!??
Posted by Alias (Alexander Prudaev) 13 Nov 2007 20:28
when you submit code
you can set option
"Reply" in "To this E-Mail address"


Re: drive me mad!!why Compilation error !!??
Posted by bottles 13 Nov 2007 20:42
many thx,it works!!