fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define mx 2010
  5. #define inf 100000000;
  6.  
  7. int Dis[mx],Node,Edge,a[mx],b[mx],c[mx];
  8.  
  9. int Belmanford();
  10.  
  11. int main(){
  12. int qtdRepeticoes, i;
  13.  
  14. cin >> qtdRepeticoes;
  15.  
  16. while(qtdRepeticoes > 0){
  17. cin >> Node >> Edge;
  18.  
  19. for(i = 0; i < Edge; i++){
  20. cin >> a[i] >> b[i] >> c[i]);
  21. }
  22.  
  23. if(Belmanford()){
  24. cout << "possible\n";
  25. }
  26. else{
  27. cout << "not possible\n";
  28. }
  29.  
  30. qtdRepeticoes --;
  31. }
  32. return 0;
  33. }
  34.  
  35. int Belmanford(){
  36. int i, j;
  37.  
  38. for(i = 0; i <= Node; i++){
  39. Dis[i]=inf;
  40. }
  41.  
  42. for(i = 0; i < Node; i++){
  43. for(j = 0; j < Edge; j++){
  44. if(Dis[b[j]] > Dis[a[j]]+c[j]){
  45. Dis[b[j]] = Dis[a[j]] + c[j];
  46. }
  47. }
  48. }
  49.  
  50. for(i = 0; i < Edge; i++){
  51. if(Dis[b[i]] > Dis[a[i]] + c[i]){
  52. return 1;
  53. }
  54. }
  55.  
  56. return 0;
  57. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
3 3
0 1 1000
1 2 15
2 1 -42
4 4
0 1 10
1 2 20
2 3 30
3 0 -60
compilation info
prog.cpp: In function 'int main()':
prog.cpp:20:40: error: expected ';' before ')' token
             cin >> a[i] >> b[i] >> c[i]);
                                        ^
stdout
Standard output is empty