fork(2) download
  1. #include<bits/stdc++.h>
  2.  
  3. void fastscan(int &number)
  4. {
  5. //variable to indicate sign of input number
  6. bool negative = false;
  7. register int c;
  8.  
  9. number = 0;
  10.  
  11. // extract current character from buffer
  12. c = getchar();
  13. if (c=='-')
  14. {
  15. // number is negative
  16. negative = true;
  17.  
  18. // extract the next character from the buffer
  19. c = getchar();
  20. }
  21.  
  22. // Keep on extracting characters if they are integers
  23. // i.e ASCII Value lies from '0'(48) to '9' (57)
  24. for (; (c>47 && c<58); c=getchar())
  25. number = number *10 + c - 48;
  26.  
  27. // if scanned input has a negative sign, negate the
  28. // value of the input number
  29. if (negative)
  30. number *= -1;
  31. }
  32. using namespace std;
  33.  
  34. int main()
  35. {
  36. int a,b,c,d,e,f,g,h,i,j,k,l,cost=0,mini=0,aa,bb=0,cc;
  37. fastscan(a);fastscan(b);bool ar[a+1];
  38. int arr[a+1];
  39. vector < int > arr2[a+1];
  40. for(c=1;c<=a;c++)
  41. {fastscan(arr[c]);arr2[c].clear();}//cost
  42. int arr5[a+1];
  43. memset(arr5,0,sizeof(arr5));
  44. for(c=0;c<b;c++)
  45. {
  46. fastscan(d);fastscan(e);
  47. arr2[d].push_back(e);//edges
  48. arr2[e].push_back(d);//edges
  49. }
  50. for(c=1;c<=a;c++)
  51. {cout<<"value of node"<<c<<"\n";
  52. for(d=0;d<arr2[c].size();d++)
  53. {
  54. cout<<arr2[c][d]<<" ";
  55. }
  56. cout<<"\n";
  57. }
  58. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty