fork download
  1. struct Edge{
  2. ll idx, dist, fee;
  3. Edge(int _idx = 0, ll _dist = 0, ll _fee = 0){
  4. idx = _idx; dist = _dist; fee = _fee;
  5. }
  6. };
  7.  
  8. int n, g;
  9. vector<Edge> adj[N];
  10.  
  11. int res;
  12. ll numGold[N], numFuel[N];
  13.  
  14. void dfsGold(int u, int p, int g){
  15. numGold[u] = g;
  16. for(auto x : adj[u]) if(x.idx != p){
  17. int v = x.idx; ll fee = x.fee;
  18. dfsGold(v, u, g + fee);
  19. }
  20. }
  21.  
  22. void dfsFuel(int u, int p, ll g, ll d){
  23. numFuel[u] = d;
  24. for(auto x : adj[u]) if(x.idx != p){
  25. int v = x.idx; ll fee = x.fee; ll w = x.dist;
  26. dfsFuel(v, u, g - fee, d + (g - fee)*w);
  27. }
  28. }
  29.  
  30. void solve(){
  31. int q; cin >> q;
  32. while(q--){
  33. int t; cin >> t;
  34. if(t == 0){
  35. int x, y, w; cin >> x >> y >> w;
  36. for(auto &v : adj[x])
  37. if(v.idx == y) v.fee = w;
  38. for(auto &v : adj[y])
  39. if(v.idx == x) v.fee = w;
  40. }
  41. else{
  42. int x, y; cin >> x >> y;
  43. dfsGold(x, -1, 0);
  44. ll gold = numGold[y] + g;
  45. dfsFuel(x, -1, gold, 0);
  46. cout << numFuel[y] << '\n';
  47. }
  48. }
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:5: error: ‘ll’ does not name a type
     ll idx, dist, fee;
     ^~
prog.cpp:3:24: error: ‘ll’ has not been declared
     Edge(int _idx = 0, ll _dist = 0, ll _fee = 0){
                        ^~
prog.cpp:3:38: error: ‘ll’ has not been declared
     Edge(int _idx = 0, ll _dist = 0, ll _fee = 0){
                                      ^~
prog.cpp: In constructor ‘Edge::Edge(int, int, int)’:
prog.cpp:4:9: error: ‘idx’ was not declared in this scope
         idx = _idx; dist = _dist; fee = _fee;
         ^~~
prog.cpp:4:9: note: suggested alternative: ‘_idx’
         idx = _idx; dist = _dist; fee = _fee;
         ^~~
         _idx
prog.cpp:4:21: error: ‘dist’ was not declared in this scope
         idx = _idx; dist = _dist; fee = _fee;
                     ^~~~
prog.cpp:4:21: note: suggested alternative: ‘_dist’
         idx = _idx; dist = _dist; fee = _fee;
                     ^~~~
                     _dist
prog.cpp:4:35: error: ‘fee’ was not declared in this scope
         idx = _idx; dist = _dist; fee = _fee;
                                   ^~~
prog.cpp:4:35: note: suggested alternative: ‘_fee’
         idx = _idx; dist = _dist; fee = _fee;
                                   ^~~
                                   _fee
prog.cpp: At global scope:
prog.cpp:9:1: error: ‘vector’ does not name a type
 vector<Edge> adj[N];
 ^~~~~~
prog.cpp:12:1: error: ‘ll’ does not name a type
 ll numGold[N], numFuel[N];
 ^~
prog.cpp: In function ‘void dfsGold(int, int, int)’:
prog.cpp:15:5: error: ‘numGold’ was not declared in this scope
     numGold[u] = g;
     ^~~~~~~
prog.cpp:15:5: note: suggested alternative: ‘dfsGold’
     numGold[u] = g;
     ^~~~~~~
     dfsGold
prog.cpp:16:18: error: ‘adj’ was not declared in this scope
     for(auto x : adj[u]) if(x.idx != p){
                  ^~~
prog.cpp:17:24: error: ‘ll’ was not declared in this scope
         int v = x.idx; ll fee = x.fee;
                        ^~
prog.cpp:18:27: error: ‘fee’ was not declared in this scope
         dfsGold(v, u, g + fee);
                           ^~~
prog.cpp: At global scope:
prog.cpp:22:28: error: ‘ll’ has not been declared
 void dfsFuel(int u, int p, ll g, ll d){
                            ^~
prog.cpp:22:34: error: ‘ll’ has not been declared
 void dfsFuel(int u, int p, ll g, ll d){
                                  ^~
prog.cpp: In function ‘void dfsFuel(int, int, int, int)’:
prog.cpp:23:5: error: ‘numFuel’ was not declared in this scope
     numFuel[u] = d;
     ^~~~~~~
prog.cpp:23:5: note: suggested alternative: ‘dfsFuel’
     numFuel[u] = d;
     ^~~~~~~
     dfsFuel
prog.cpp:24:18: error: ‘adj’ was not declared in this scope
     for(auto x : adj[u]) if(x.idx != p){
                  ^~~
prog.cpp:25:24: error: ‘ll’ was not declared in this scope
         int v = x.idx; ll fee = x.fee; ll w = x.dist;
                        ^~
prog.cpp:25:42: error: expected ‘;’ before ‘w’
         int v = x.idx; ll fee = x.fee; ll w = x.dist;
                                          ^~
                                          ;
prog.cpp:26:27: error: ‘fee’ was not declared in this scope
         dfsFuel(v, u, g - fee, d + (g - fee)*w);
                           ^~~
prog.cpp:26:46: error: ‘w’ was not declared in this scope
         dfsFuel(v, u, g - fee, d + (g - fee)*w);
                                              ^
prog.cpp: In function ‘void solve()’:
prog.cpp:31:12: error: ‘cin’ was not declared in this scope
     int q; cin >> q;
            ^~~
prog.cpp:36:27: error: ‘adj’ was not declared in this scope
             for(auto &v : adj[x])
                           ^~~
prog.cpp:38:27: error: ‘adj’ was not declared in this scope
             for(auto &v : adj[y])
                           ^~~
prog.cpp:44:13: error: ‘ll’ was not declared in this scope
             ll gold = numGold[y] + g;
             ^~
prog.cpp:45:28: error: ‘gold’ was not declared in this scope
             dfsFuel(x, -1, gold, 0);
                            ^~~~
prog.cpp:45:28: note: suggested alternative: ‘void’
             dfsFuel(x, -1, gold, 0);
                            ^~~~
                            void
prog.cpp:46:13: error: ‘cout’ was not declared in this scope
             cout << numFuel[y]  << '\n';
             ^~~~
prog.cpp:46:21: error: ‘numFuel’ was not declared in this scope
             cout << numFuel[y]  << '\n';
                     ^~~~~~~
prog.cpp:46:21: note: suggested alternative: ‘dfsFuel’
             cout << numFuel[y]  << '\n';
                     ^~~~~~~
                     dfsFuel
stdout
Standard output is empty