Why I got CE? Here is my program,it runs all right on my computer,but it got CE. Can anyone help me? Thanks! #include <stdlib.h> #include <iostream.h> int way[101][101],temp[101][101]; int father[101],son[101]; int n,q; long sum,min; int used[101]; void search(int num,long m) { int i; if (num==0) { if (m<min) min=m; } else { for (i=1;i<=n;i++) if (son[i]==0 && used[i]==0) { used[i]=1; son[father[i]]--; search(num-1,m+way[father[i]][i]); son[father[i]]++; used[i]=0; } } } main() { int x,y,w,t,i,j,k; cin>>n>>q; t=0;sum=0; memset(way,0,sizeof(way)); while (cin>>x>>y>>w) { if (w==0) t++; else { way[x][y]=w; way[y][x]=w; way[x][0]++; way[y][0]++; sum+=w; } } q-=t; memset(father,0,sizeof(father)); memcpy(temp,way,sizeof(way)); memset(son,0,sizeof(son)); for (i=1;i<=n-1;i++) { for (j=2;j<=n;j++) if (temp[j][0]==1) break; for (k=1;k<=n;k++) if (temp[j][k]!=0) break; father[j]=k; temp[j][0]=0; temp[k][0]--; temp[j][k]=0;temp[k][j]=0; son[k]++; } min=sum; memset(used,0,sizeof(used)); search(q,0); sum=sum-min; cout<<sum<<endl; return(0); } Re: Why I got CE? Here is your compilation error :
You tried to solve problem 1018. Your solution on C++ was compiled with the following errors:
329286 e:\Judge\vc7\include\useoldio.h(29) : warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated temp\329286(32) : error C2065: 'memset' : undeclared identifier temp\329286(46) : error C2065: 'memcpy' : undeclared identifier 4.
My advise : before submitting any problem compile your source with a visual c 7 compiler (vc7) .
> Here is my program,it runs all right on my computer,but it got CE. > Can anyone help me? Thanks! > > > #include <stdlib.h> > #include <iostream.h> > int way[101][101],temp[101][101]; > int father[101],son[101]; > int n,q; > long sum,min; > int used[101]; > void search(int num,long m) > { > int i; > if (num==0) > { > if (m<min) min=m; > } else > { > for (i=1;i<=n;i++) > if (son[i]==0 && used[i]==0) > { > used[i]=1; > son[father[i]]--; > search(num-1,m+way[father[i]][i]); > son[father[i]]++; > used[i]=0; > } > } > } > main() > { > int x,y,w,t,i,j,k; > cin>>n>>q; > t=0;sum=0; > memset(way,0,sizeof(way)); > while (cin>>x>>y>>w) > { > if (w==0) t++; else > { > way[x][y]=w; > way[y][x]=w; > way[x][0]++; > way[y][0]++; > sum+=w; > } > } > q-=t; > memset(father,0,sizeof(father)); > memcpy(temp,way,sizeof(way)); > memset(son,0,sizeof(son)); > for (i=1;i<=n-1;i++) > { > for (j=2;j<=n;j++) > if (temp[j][0]==1) break; > for (k=1;k<=n;k++) > if (temp[j][k]!=0) break; > father[j]=k; > temp[j][0]=0; > temp[k][0]--; > temp[j][k]=0;temp[k][j]=0; > son[k]++; > } > min=sum; > memset(used,0,sizeof(used)); > search(q,0); > sum=sum-min; > cout<<sum<<endl; > return(0); > } > > > > > > > > > Thank you very much! > Here is your compilation error : > > You tried to solve problem 1018. Your solution on C++ was compiled > with > the following errors: > > 329286 > e:\Judge\vc7\include\useoldio.h(29) : warning C4995: > '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma > deprecated > temp\329286(32) : error C2065: 'memset' : undeclared identifier > temp\329286(46) : error C2065: 'memcpy' : undeclared identifier > 4. > > > > My advise : before submitting any problem compile your source with a > visual c 7 compiler (vc7) . > > > Here is my program,it runs all right on my computer,but it got CE. > > Can anyone help me? Thanks! > > > > > > #include <stdlib.h> > > #include <iostream.h> > > int way[101][101],temp[101][101]; > > int father[101],son[101]; > > int n,q; > > long sum,min; > > int used[101]; > > void search(int num,long m) > > { > > int i; > > if (num==0) > > { > > if (m<min) min=m; > > } else > > { > > for (i=1;i<=n;i++) > > if (son[i]==0 && used[i]==0) > > { > > used[i]=1; > > son[father[i]]--; > > search(num-1,m+way[father[i]][i]); > > son[father[i]]++; > > used[i]=0; > > } > > } > > } > > main() > > { > > int x,y,w,t,i,j,k; > > cin>>n>>q; > > t=0;sum=0; > > memset(way,0,sizeof(way)); > > while (cin>>x>>y>>w) > > { > > if (w==0) t++; else > > { > > way[x][y]=w; > > way[y][x]=w; > > way[x][0]++; > > way[y][0]++; > > sum+=w; > > } > > } > > q-=t; > > memset(father,0,sizeof(father)); > > memcpy(temp,way,sizeof(way)); > > memset(son,0,sizeof(son)); > > for (i=1;i<=n-1;i++) > > { > > for (j=2;j<=n;j++) > > if (temp[j][0]==1) break; > > for (k=1;k<=n;k++) > > if (temp[j][k]!=0) break; > > father[j]=k; > > temp[j][0]=0; > > temp[k][0]--; > > temp[j][k]=0;temp[k][j]=0; > > son[k]++; > > } > > min=sum; > > memset(used,0,sizeof(used)); > > search(q,0); > > sum=sum-min; > > cout<<sum<<endl; > > return(0); > > } > > > > > > > > > > > > > > > > > > Search if wrong! > Here is your compilation error : > > You tried to solve problem 1018. Your solution on C++ was compiled > with > the following errors: > > 329286 > e:\Judge\vc7\include\useoldio.h(29) : warning C4995: > '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma > deprecated > temp\329286(32) : error C2065: 'memset' : undeclared identifier > temp\329286(46) : error C2065: 'memcpy' : undeclared identifier > 4. > > > > My advise : before submitting any problem compile your source with a > visual c 7 compiler (vc7) . > > > Here is my program,it runs all right on my computer,but it got CE. > > Can anyone help me? Thanks! > > > > > > #include <stdlib.h> > > #include <iostream.h> > > int way[101][101],temp[101][101]; > > int father[101],son[101]; > > int n,q; > > long sum,min; > > int used[101]; > > void search(int num,long m) > > { > > int i; > > if (num==0) > > { > > if (m<min) min=m; > > } else > > { > > for (i=1;i<=n;i++) > > if (son[i]==0 && used[i]==0) > > { > > used[i]=1; > > son[father[i]]--; > > search(num-1,m+way[father[i]][i]); > > son[father[i]]++; > > used[i]=0; > > } > > } > > } > > main() > > { > > int x,y,w,t,i,j,k; > > cin>>n>>q; > > t=0;sum=0; > > memset(way,0,sizeof(way)); > > while (cin>>x>>y>>w) > > { > > if (w==0) t++; else > > { > > way[x][y]=w; > > way[y][x]=w; > > way[x][0]++; > > way[y][0]++; > > sum+=w; > > } > > } > > q-=t; > > memset(father,0,sizeof(father)); > > memcpy(temp,way,sizeof(way)); > > memset(son,0,sizeof(son)); > > for (i=1;i<=n-1;i++) > > { > > for (j=2;j<=n;j++) > > if (temp[j][0]==1) break; > > for (k=1;k<=n;k++) > > if (temp[j][k]!=0) break; > > father[j]=k; > > temp[j][0]=0; > > temp[k][0]--; > > temp[j][k]=0;temp[k][j]=0; > > son[k]++; > > } > > min=sum; > > memset(used,0,sizeof(used)); > > search(q,0); > > sum=sum-min; > > cout<<sum<<endl; > > return(0); > > } > > > > > > > > > > > > > > > > > > Search if wrong! You'd better use dynamic! And of course be CE! I'm sorry,search is wrong! > You'd better use dynamic! > And of course be CE! |