|
|
back to boardCrash (access violation) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! on test # 1...................... if i get it again, i'm gonna break something.... it runs perfectly on my compiler #include <stdio.h> #include <iostream> #include <vector> #define PB push_back using namespace std; int lev[110]; int main() { int i,j,k,l,n,s,e,v; int q[10100]; vector<int> a[110]; scanf("%d",&n); // cin>>n; for (i=1; i<=n; i++) { while (1) { scanf("%d",&j); // cin>>j; if (j!=0) a[i].PB(j); else break; } } for (i=1; i<=n; i++) if (!lev[i]) { q[0]=i; e=0; for (s=0; s<=e; s++) { for (j=0; j<a[q[s]].size(); j++) { v=a[q[s]][j]; lev[v]=lev[q[s]]+1; q[e++]=v; } } } vector<int> ans; for (i=1; i<=n; i++) if (lev[i]%2) ans.PB(i); printf("%d\n",ans.size()); for (i=0;i<ans.size()-1; i++) printf("%d ",ans[i]); printf("%d\n",ans[ans.size()-1]); return 0; } Re: Crash (access violation) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 0 0 Re: Crash (access violation) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 0 0 Every member has one or more friends in the group!!! Re: Crash (access violation) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Posted by Bogatyr 22 Nov 2012 03:47 > Every member has one or more friends in the group!!! The problem statement does not say this. It says that friendship is mutual (the friendship must exist for this to be true), and that the friendship list is terminated by a 0. So it is allowed for a member to have no friends. |
|
|