Stavo provando a risolvere questo problema la maggior parte dei test case me li da corretti non capisco dove stia l’errore
// NOTE: it is recommended to use this even if you don't understand the following code.
#include<bits/stdc++.h>
using namespace std;
// input data
int N, M, T;
vector<int> A, B, C, E;
int main() {
// uncomment the following lines if you want to read/write from files
// ifstream cin("input22.txt");
// ofstream cout("output.txt");
cin >> N >> M >> T;
A.resize(M);
B.resize(M);
C.resize(M);
E.resize(M);
for (int i=0; i<M; i++)
cin >> A[i] >> B[i] >> C[i] >> E[i];
// insert your code here
vector<vector<int>>lda(N);
vector<vector<int>>ce(N);
for(int i = 0;i<M;i++){
lda[A[i]].push_back(B[i]);
ce[A[i]].push_back(C[i]);
ce[A[i]].push_back(E[i]);
}
vector<int>dist(N);
vector<bool>v(N);
for(int i = 0;i<N;i++)v[i] = false;
for(int i = 0;i<N;i++)dist[i] = INT_MAX;
queue<int>q;
q.push(0);
dist[0] = 0;
int j;
while(!q.empty()){
int n = q.front();
q.pop();
if(v[n])continue;
v[n] = true;
j = 0;
for(int i : lda[n]){
if(!v[i]){
q.push(i);
if(dist[n]+ce[n][j*2] < dist[i]){
if((dist[n]+ce[n][j*2] <= T && ce[n][j*2+1]) || !ce[n][j*2+1])dist[i] = dist[n]+ce[n][j*2];
}
}
j++;
}
}
if(dist[N-1] == INT_MAX)dist[N-1] = -1;
cout << dist[N-1] << endl; // print the result
return 0;
}