#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{A_x}
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

JZOI1134 迷宫(maze)的更多相关文章

  1. 迷宫 maze

    1 #include <stdlib.h> #include <stdio.h> #define stackinitsize 50 #define stackincrement ...

  2. 数据结构算法C语言实现(八)--- 3.2栈的应用举例:迷宫求解与表达式求值

    一.简介 迷宫求解:类似图的DFS.具体的算法思路可以参考书上的50.51页,不过书上只说了粗略的算法,实现起来还是有很多细节需要注意.大多数只是给了个抽象的名字,甚至参数类型,返回值也没说的很清楚, ...

  3. golang 实现广度优先算法(走迷宫)

    maze.go package main import ( "fmt" "os" ) /** * 广度优先算法 */ /** * 从文件中读取数据 */ fun ...

  4. php生成迷宫和迷宫寻址算法实例

    较之前的终于有所改善.生成迷宫的算法和寻址算法其实是一样.只是一个用了遍历一个用了递归.参考了网上的Mike Gold的算法. <?php //zairwolf z@cot8.com heade ...

  5. 【noip 模拟赛curse,light,maze】 题解

    2018.10.16 总结:考的不好 原因: 1.考的时候没状态,读题读不进去 2.考的时候不仔细,该得分没得到 T1:curse 1.咒语 (curse.pas/c/cpp) [题目描述] 亮亮梦到 ...

  6. maze writeup

    maze writeup 攻防世界的一道迷宫题,第一次接触这样的题,个人感觉很有意思,收获也挺多,做一篇笔记记录一下. 程序分析 __int64 sub_4006B0() { signed __int ...

  7. [python 译] 基于面向对象的分析和设计

    [python 译] 基于面向对象的分析和设计 // */ // ]]>   [python 译] 基于面向对象的分析和设计 Table of Contents 1 原文地址 2 引言 2.1 ...

  8. 面向对象设计——抽象工厂(Abstract Factory)模式

    定义 提供一个创建一系列相关或者相互依赖对象的接口,而无需指定它们具体的类.抽象工厂允许客户使用抽象的接口来创建一组相关的产品,而不需要知道或关心实际产出的具体产品是什么.这样一来,客户就能从具体的产 ...

  9. 设计模式之生成器(Builder)模式

    意图 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以表示不同的表示. 适用性 当创建复杂对象的算法应该独立于该对象的组成部分以及它们的装配方式时. 当构造过程必须允许被构造的对象有不同的表 ...

随机推荐

  1. PHP FILTER_SANITIZE_STRING 过滤器

    定义和用法 FILTER_SANITIZE_STRING 过滤器去除或编码不需要的字符. 该过滤器删除那些对应用程序有潜在危害的数据.它用于去除标签以及删除或编码不需要的字符. Name: " ...

  2. 【从0到1,搭建Spring Boot+RESTful API+Shiro+Mybatis+SQLServer权限系统】05、Shiro集成

    1.POM文件中加入Shiro和fastJSON依赖 <dependency> <groupId>org.apache.shiro</groupId> <ar ...

  3. MySQL 5.7配置文件

    原文:http://www.voidcn.com/article/p-zrikccdi-hr.html # MySql5.7配置文件my.cnf设置[client]port = 3306socket ...

  4. 【git】如何ignore一个文件的更改又保留其初始版本

    参考: https://compiledsuccessfully.dev/git-skip-worktree/ https://stackoverflow.com/questions/9794931/ ...

  5. eclipse 集成 STS 插件

    eclipse 集成 STS 插件 想新建一个 Spring Boot 工程,发现没有,如图:(展示的是集成之后的) eclipse 要和 sts 版本对应的,进入http://spring.io/t ...

  6. yum安装apache

    一.查询是否已经安装apache rpm  -qa  httpd 注:Apache在linux系统里的名字是httpd 如果有返回的信息,则会显示已经安装的软件.如果没有则不会显示其它的信息.如下图是 ...

  7. XStream教程

    XStream是一个简单的基于Java库,Java对象序列化到XML,反之亦然(即:可以轻易的将Java对象和xml文档相互转换). 特点 使用方便 - XStream的API提供了一个高层次外观,以 ...

  8. markdown_TestOne

    这个是我写的一个markdown尝试 1.2 dafsdfeasdfaefasdfase afsdfasdfefasdfeadfasdfe

  9. vue.js实现用户评论、登录、注册、及修改信息功能

    vue.js实现用户评论.登录.注册.及修改信息功能:https://www.jb51.net/article/113799.htm

  10. mysql全局权限账户%登录不上ERROR 1045 (28000): Access denied for user 'zzq'@'localhost' (using password: YES)

    mysql中有新建了一个%(允许所有主机连接)和ALL权限的账户.但是竟然连不上.用root或者其他localhost的用户却可以登录.首先检查下防火墙打开了没,可以用service iptables ...