#include <bits/stdc++.h>
#define ll long long
#define INF 2147483647
#define mem_INF 2139062143
#define ll_INF 9223372036854775807
#define eps 1e-8
#define fuckrand() ( ( rand() << 15 ) ^ rand() )
using namespace std;
inline int read() {
int x = 0,tmp = 1;char ch = getchar();
while( ch < '0' || ch > '9' ) {if ( ch == '-' ) tmp = -1; ch = getchar();}
while( ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar(); }
return x * tmp;
}
struct Node {
int to, next, t, w;
} edge[21000];
bool used[11000];
int N, M, __t__, v;
int head[110], idx = 0, ans_t = __t__, ans_w = 0;
inline void ade( int u, int v, int t, int w ) {
edge[++ idx].to = v;
edge[idx].w = w;
edge[idx].t = t;
edge[idx].next = head[u];
head[u] = idx;
}
inline void add( int u, int v, int t, int w ) {
ade( u, v, t, w );
ade( v, u, t, w );
}
void dfs( int now, int t, int w ) {
if( t > __t__ || w > v ) return;
else if( now == N ) {
if( w < ans_w ) return;
if( w > ans_w ) {
ans_w = w;
ans_t = t;
} else if( w == ans_w ) ans_t = min( t, ans_t );
return;
} else {
for( int i = head[now] ; i != -1 ; i = edge[i].next ) if( !used[( i + 1 ) >> 1] ){
int son = edge[i].to, _t = edge[i].t, _w = edge[i].w;
used[( i + 1 ) >> 1] = 1;
dfs( son, t + _t, w + _w );
used[( i + 1 ) >> 1] = 0;
}
}
}
int main() {
memset( head, -1, sizeof( head ) );
memset( used, 0, sizeof( used ) );
N = read(), M = read(), __t__ = read(), v = read();
for( int i = 1 ; i <= M ; ++ i ) {
int u = read(), v = read(), t = read(), w = read();
ade( u, v, t, w );
ade( v, u, t, w );
}
dfs( 1, 0, 0 );
printf( "%d %d\n", ans_t, v - ans_w );
return 0;
}
--数据点-- |
---N--- |
---Q--- |
max |
1 |
3 |
3 |
10 |
2 |
10 |
10 |
10000 |
3 |
10 |
10 |
10000 |
4 |
10 |
10000 |
10000 |
5 |
26 |
10000 |
100000000 |
6 |
26 |
10000 |
100000000 |
7 |
26 |
10000 |
1000000000000 |
8 |
26 |
10000 |
10000000000000000 |
9 |
26 |
50000 |
10000000000000000 |
10 |
26 |
100000 |
10000000000000000 |