fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() { int t,n,m,cnt,cnt1,flag,time=0; short int res; unsigned long int st; unsigned long int b;
  5.  
  6. cin>>t; cnt=t; res=new short int*[t];
  7.  
  8. while(t) { cnt1=0; time=0;
  9.  
  10. cin>>n;
  11. cin>>m;
  12. cin>>b;
  13.  
  14. res[cnt-t]=new short int[m+1];
  15.  
  16. //allocation
  17. st=new unsigned long int*[m];
  18. for(int i=0;i<m;i++)
  19. {
  20. st[i]=new unsigned long int[4];
  21. }
  22.  
  23. for(int i=0;i<m;i++)
  24. {
  25. cin>>st[i][0];
  26. cin>>st[i][1];
  27. cin>>st[i][2];
  28. st[i][3]=0;
  29. }
  30.  
  31. unsigned long int min;
  32. int dest=0,minj=-1;
  33.  
  34.  
  35. for(int i=0;i<m && time<b;i++)
  36. {
  37. min=1000000001;
  38. for(int j=0;j<m;j++)
  39. {
  40. if(st[j][0]==dest && min>st[j][2] && !st[j][3])
  41. {
  42. min=st[j][2];
  43. minj=j;
  44. }
  45. }
  46. st[minj][3]=1;
  47. flag=1;
  48. for(int k=0;k<cnt1;k++)
  49. {
  50. if(res[cnt-t][k]==st[minj][1])
  51. {
  52. flag=0;
  53. }
  54. }
  55.  
  56. if(flag)
  57. {
  58. res[cnt-t][cnt1++]=st[minj][1];
  59. }
  60.  
  61. dest=st[minj][1];
  62. time+=min;
  63. }
  64.  
  65. res[cnt-t][cnt1]=-1;
  66.  
  67. //deallocation
  68. for(int i=0;i<m;i++)
  69. {
  70. delete [] st[i];
  71. }
  72. delete [] st;
  73.  
  74. t--;
  75. }
  76.  
  77. int j; for(int i=0;i<cnt;i++) { j=0; while(res[i][j]!=-1) { cout<<res[i][j++]<<" "; } cout<<"-1"; cout<<"\n"; }
  78.  
  79. for(int i=0;i<cnt;i++) { delete [] res[i]; } delete [] res;
  80.  
  81. return 0; }
  82.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
3 4 2
0 1 1
0 2 1
1 2 1
2 1 2
5 7 11
0 1 2
1 0 3
0 2 1
2 3 2
3 2 3
2 4 1
4 2 2
compilation info
prog.c:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
stdout
Standard output is empty